mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
1) Added 'Ignore Grants' option in the schema diff tool. #5759
2) Added 'Ignore Tablespace' option in the schema diff tool. #6004 3) Ensure that Schema Diff comparison results should be displayed in the sorted order. #6595 4) Fixed an issue where the SET directive is excluded from the function header in the schema diff tool. #6651
This commit is contained in:
@@ -73,7 +73,7 @@ class SchemaDiffModule(PgAdminModule):
|
||||
|
||||
self.preference.register(
|
||||
'display', 'ignore_whitespaces',
|
||||
gettext("Ignore whitespace"), 'boolean', False,
|
||||
gettext("Ignore Whitespace"), 'boolean', False,
|
||||
category_label=PREF_LABEL_DISPLAY,
|
||||
help_str=gettext('Set ignore whitespace on or off by default in '
|
||||
'the drop-down menu near the Compare button in '
|
||||
@@ -82,13 +82,31 @@ class SchemaDiffModule(PgAdminModule):
|
||||
|
||||
self.preference.register(
|
||||
'display', 'ignore_owner',
|
||||
gettext("Ignore owner"), 'boolean', False,
|
||||
gettext("Ignore Owner"), 'boolean', False,
|
||||
category_label=PREF_LABEL_DISPLAY,
|
||||
help_str=gettext('Set ignore owner on or off by default in the '
|
||||
'drop-down menu near the Compare button in the '
|
||||
'Schema Diff tab.')
|
||||
)
|
||||
|
||||
self.preference.register(
|
||||
'display', 'ignore_tablespace',
|
||||
gettext("Ignore Tablespace"), 'boolean', False,
|
||||
category_label=PREF_LABEL_DISPLAY,
|
||||
help_str=gettext('Set ignore tablespace on or off by default in '
|
||||
'the drop-down menu near the Compare button in '
|
||||
'the Schema Diff tab.')
|
||||
)
|
||||
|
||||
self.preference.register(
|
||||
'display', 'ignore_grants',
|
||||
gettext("Ignore Grants/Revoke"), 'boolean', False,
|
||||
category_label=PREF_LABEL_DISPLAY,
|
||||
help_str=gettext('Set ignore grants/revoke on or off by default '
|
||||
'in the drop-down menu near the Compare button '
|
||||
'in the Schema Diff tab.')
|
||||
)
|
||||
|
||||
|
||||
blueprint = SchemaDiffModule(MODULE_NAME, __name__, static_url_path='/static')
|
||||
|
||||
@@ -462,6 +480,8 @@ def compare_database(params):
|
||||
try:
|
||||
ignore_owner = bool(params['ignore_owner'])
|
||||
ignore_whitespaces = bool(params['ignore_whitespaces'])
|
||||
ignore_tablespace = bool(params['ignore_tablespace'])
|
||||
ignore_grants = bool(params['ignore_grants'])
|
||||
|
||||
# Fetch all the schemas of source and target database
|
||||
# Compare them and get the status.
|
||||
@@ -476,7 +496,7 @@ def compare_database(params):
|
||||
node_percent = 0
|
||||
if total_schema > 0:
|
||||
node_percent = round(100 / (total_schema * len(
|
||||
SchemaDiffRegistry.get_registered_nodes())))
|
||||
SchemaDiffRegistry.get_registered_nodes())), 2)
|
||||
total_percent = 0
|
||||
|
||||
# Compare Database objects
|
||||
@@ -489,7 +509,9 @@ def compare_database(params):
|
||||
target_did=params['target_did'],
|
||||
diff_model_obj=diff_model_obj, total_percent=total_percent,
|
||||
node_percent=node_percent, ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
comparison_result = \
|
||||
comparison_result + comparison_schema_result
|
||||
|
||||
@@ -511,7 +533,9 @@ def compare_database(params):
|
||||
node_percent=node_percent,
|
||||
is_schema_source_only=True,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
comparison_result = \
|
||||
comparison_result + comparison_schema_result
|
||||
@@ -532,7 +556,9 @@ def compare_database(params):
|
||||
total_percent=total_percent,
|
||||
node_percent=node_percent,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
comparison_result = \
|
||||
comparison_result + comparison_schema_result
|
||||
@@ -555,7 +581,9 @@ def compare_database(params):
|
||||
total_percent=total_percent,
|
||||
node_percent=node_percent,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
comparison_result = \
|
||||
comparison_result + comparison_schema_result
|
||||
@@ -597,8 +625,10 @@ def compare_schema(params):
|
||||
try:
|
||||
ignore_owner = bool(params['ignore_owner'])
|
||||
ignore_whitespaces = bool(params['ignore_whitespaces'])
|
||||
ignore_tablespace = bool(params['ignore_tablespace'])
|
||||
ignore_grants = bool(params['ignore_grants'])
|
||||
all_registered_nodes = SchemaDiffRegistry.get_registered_nodes()
|
||||
node_percent = round(100 / len(all_registered_nodes))
|
||||
node_percent = round(100 / len(all_registered_nodes), 2)
|
||||
total_percent = 0
|
||||
|
||||
comparison_schema_result, total_percent = \
|
||||
@@ -615,7 +645,9 @@ def compare_schema(params):
|
||||
total_percent=total_percent,
|
||||
node_percent=node_percent,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
comparison_result = \
|
||||
comparison_result + comparison_schema_result
|
||||
@@ -749,6 +781,8 @@ def compare_database_objects(**kwargs):
|
||||
node_percent = kwargs.get('node_percent')
|
||||
ignore_owner = kwargs.get('ignore_owner')
|
||||
ignore_whitespaces = kwargs.get('ignore_whitespaces')
|
||||
ignore_tablespace = kwargs.get('ignore_tablespace')
|
||||
ignore_grants = kwargs.get('ignore_grants')
|
||||
comparison_result = []
|
||||
|
||||
all_registered_nodes = SchemaDiffRegistry.get_registered_nodes(None,
|
||||
@@ -772,7 +806,9 @@ def compare_database_objects(**kwargs):
|
||||
target_did=target_did,
|
||||
group_name=gettext('Database Objects'),
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
if res is not None:
|
||||
comparison_result = comparison_result + res
|
||||
@@ -803,6 +839,8 @@ def compare_schema_objects(**kwargs):
|
||||
is_schema_source_only = kwargs.get('is_schema_source_only', False)
|
||||
ignore_owner = kwargs.get('ignore_owner')
|
||||
ignore_whitespaces = kwargs.get('ignore_whitespaces')
|
||||
ignore_tablespace = kwargs.get('ignore_tablespace')
|
||||
ignore_grants = kwargs.get('ignore_grants')
|
||||
|
||||
source_schema_name = None
|
||||
if is_schema_source_only:
|
||||
@@ -839,12 +877,14 @@ def compare_schema_objects(**kwargs):
|
||||
group_name=gettext(schema_name),
|
||||
source_schema_name=source_schema_name,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
if res is not None:
|
||||
comparison_result = comparison_result + res
|
||||
total_percent = total_percent + node_percent
|
||||
# if total_percent is more then 100 then set it to less then 100
|
||||
# if total_percent is more than 100 then set it to less than 100
|
||||
if total_percent >= 100:
|
||||
total_percent = 96
|
||||
|
||||
|
@@ -59,6 +59,8 @@ class SchemaDiffObjectCompare:
|
||||
'did': kwargs.get('target_did')}
|
||||
ignore_owner = kwargs.get('ignore_owner', False)
|
||||
ignore_whitespaces = kwargs.get('ignore_whitespaces', False)
|
||||
ignore_tablespace = kwargs.get('ignore_tablespace', False)
|
||||
ignore_grants = kwargs.get('ignore_grants', False)
|
||||
|
||||
group_name = kwargs.get('group_name')
|
||||
source_schema_name = kwargs.get('source_schema_name', None)
|
||||
@@ -102,7 +104,9 @@ class SchemaDiffObjectCompare:
|
||||
ignore_keys=self.keys_to_ignore,
|
||||
source_schema_name=source_schema_name,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
def ddl_compare(self, **kwargs):
|
||||
"""
|
||||
|
@@ -253,6 +253,8 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict,
|
||||
group_name = kwargs['group_name']
|
||||
target_schema = kwargs.get('target_schema')
|
||||
ignore_whitespaces = kwargs.get('ignore_whitespaces')
|
||||
ignore_grants = kwargs.get('ignore_grants', False)
|
||||
|
||||
for key in intersect_keys:
|
||||
source_object_id, target_object_id = \
|
||||
get_source_target_oid(source_dict, target_dict, key)
|
||||
@@ -299,7 +301,10 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict,
|
||||
ignore_keys=temp_ignore_keys,
|
||||
difference={}
|
||||
)
|
||||
parse_acl(dict1[key], dict2[key], diff_dict)
|
||||
|
||||
# No need to parse acl if ignore_grants is set to True.
|
||||
if not ignore_grants:
|
||||
parse_acl(dict1[key], dict2[key], diff_dict)
|
||||
|
||||
temp_src_params['tid'] = source_object_id
|
||||
temp_tgt_params['tid'] = target_object_id
|
||||
@@ -326,7 +331,10 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict,
|
||||
dict1[key], dict2[key],
|
||||
ignore_keys=view_object.keys_to_ignore, difference={}
|
||||
)
|
||||
parse_acl(dict1[key], dict2[key], diff_dict)
|
||||
|
||||
# No need to parse acl if ignore_grants is set to True.
|
||||
if not ignore_grants:
|
||||
parse_acl(dict1[key], dict2[key], diff_dict)
|
||||
|
||||
temp_src_params['oid'] = source_object_id
|
||||
temp_tgt_params['oid'] = target_object_id
|
||||
@@ -387,6 +395,8 @@ def compare_dictionaries(**kwargs):
|
||||
source_schema_name = kwargs.get('source_schema_name')
|
||||
ignore_owner = kwargs.get('ignore_owner')
|
||||
ignore_whitespaces = kwargs.get('ignore_whitespaces')
|
||||
ignore_tablespace = kwargs.get('ignore_tablespace')
|
||||
ignore_grants = kwargs.get('ignore_grants')
|
||||
|
||||
dict1 = copy.deepcopy(source_dict)
|
||||
dict2 = copy.deepcopy(target_dict)
|
||||
@@ -421,10 +431,22 @@ def compare_dictionaries(**kwargs):
|
||||
# ignore keys.
|
||||
if ignore_owner:
|
||||
owner_keys = ['owner', 'eventowner', 'funcowner', 'fdwowner',
|
||||
'fsrvowner', 'lanowner', 'relowner', 'relacl', 'acl',
|
||||
'seqowner', 'typeowner']
|
||||
'fsrvowner', 'lanowner', 'relowner', 'seqowner',
|
||||
'typeowner']
|
||||
ignore_keys = ignore_keys + owner_keys
|
||||
|
||||
# if ignore_tablespace is True then add all the possible tablespace keys
|
||||
# to the ignore keys.
|
||||
if ignore_tablespace:
|
||||
tablespace_keys = ['spcname', 'spcoid']
|
||||
ignore_keys = ignore_keys + tablespace_keys
|
||||
|
||||
# if ignore_grants is True then add all the possible grants keys
|
||||
# to the ignore keys.
|
||||
if ignore_grants:
|
||||
grant_keys = ['relacl', 'acl', 'datacl', 'fdwacl', 'lanacl', 'fsrvacl']
|
||||
ignore_keys = ignore_keys + grant_keys
|
||||
|
||||
# Compare the values of duplicates keys.
|
||||
other_param = {
|
||||
"dict1": dict1,
|
||||
@@ -434,7 +456,8 @@ def compare_dictionaries(**kwargs):
|
||||
"target_params": target_params,
|
||||
"group_name": group_name,
|
||||
"target_schema": target_schema,
|
||||
"ignore_whitespaces": ignore_whitespaces
|
||||
"ignore_whitespaces": ignore_whitespaces,
|
||||
"ignore_grants": ignore_grants
|
||||
}
|
||||
|
||||
identical, different = _get_identical_and_different_list(
|
||||
@@ -486,11 +509,12 @@ def are_dictionaries_identical(source_dict, target_dict, ignore_keys,
|
||||
"""
|
||||
src_keys = set(source_dict.keys())
|
||||
tar_keys = set(target_dict.keys())
|
||||
igr_keys = set(ignore_keys)
|
||||
|
||||
# Keys that are available in source and missing in target.
|
||||
src_only = src_keys - tar_keys
|
||||
src_only = (src_keys - igr_keys) - tar_keys
|
||||
# Keys that are available in target and missing in source.
|
||||
tar_only = tar_keys - src_keys
|
||||
tar_only = (tar_keys - igr_keys) - src_keys
|
||||
|
||||
# If number of keys are different in source and target then
|
||||
# return False
|
||||
@@ -590,11 +614,12 @@ def directory_diff(source_dict, target_dict, ignore_keys=[], difference=None):
|
||||
difference = {} if difference is None else difference
|
||||
src_keys = set(source_dict.keys())
|
||||
tar_keys = set(target_dict.keys())
|
||||
igr_keys = set(ignore_keys)
|
||||
|
||||
# Keys that are available in source and missing in target.
|
||||
src_only = src_keys - tar_keys
|
||||
src_only = (src_keys - igr_keys) - tar_keys
|
||||
# Keys that are available in target and missing in source.
|
||||
tar_only = tar_keys - src_keys
|
||||
tar_only = (tar_keys - igr_keys) - src_keys
|
||||
|
||||
for key in source_dict.keys():
|
||||
added = []
|
||||
|
@@ -34,7 +34,9 @@ export const STYLE_CONSTANT = {
|
||||
|
||||
export const MENUS_COMPARE_CONSTANT = {
|
||||
COMPARE_IGNORE_OWNER: 1,
|
||||
COMPARE_IGNORE_WHITESPACE: 2
|
||||
COMPARE_IGNORE_WHITESPACE: 2,
|
||||
COMPARE_IGNORE_TABLESPACE: 3,
|
||||
COMPARE_IGNORE_GRANTS: 4
|
||||
};
|
||||
|
||||
export const MENUS_FILTER_CONSTANT = {
|
||||
@@ -63,3 +65,10 @@ export const FILTER_NAME = {
|
||||
SOURCE_ONLY: gettext('Source Only'),
|
||||
TARGET_ONLY: gettext('Target Only')
|
||||
};
|
||||
|
||||
export const IGNORE_OPTION = {
|
||||
OWNER : gettext('Ignore Owner'),
|
||||
WHITESPACE : gettext('Ignore Whitespace'),
|
||||
TABLESPACE: gettext('Ignore Tablespace'),
|
||||
GRANTS: gettext('Ignore Grant/Revoke')
|
||||
};
|
||||
|
@@ -371,13 +371,17 @@ function prepareRows(rows, gridData, filterParams) {
|
||||
|
||||
let adedIds = [];
|
||||
gridData.map((record) => {
|
||||
let childrens = getChildrenRows(record);
|
||||
let children = getChildrenRows(record);
|
||||
// Sort the children using label
|
||||
children.sort((a, b) => (a.label > b.label) ? 1 : -1);
|
||||
|
||||
if (childrens.length > 0) {
|
||||
childrens.map((child) => {
|
||||
let subChildrens = getChildrenRows(child);
|
||||
if (children.length > 0) {
|
||||
children.map((child) => {
|
||||
let subChildren = getChildrenRows(child);
|
||||
// Sort the sub children using label
|
||||
subChildren.sort((a, b) => (a.label > b.label) ? 1 : -1);
|
||||
let tempChildList = [];
|
||||
subChildrens.map((subChild) => {
|
||||
subChildren.map((subChild) => {
|
||||
if (filterParams.includes(subChild.status)) {
|
||||
tempChildList.push(subChild);
|
||||
adedIds.push(subChild.id);
|
||||
|
@@ -17,13 +17,12 @@ import { Box } from '@material-ui/core';
|
||||
import CompareArrowsRoundedIcon from '@material-ui/icons/CompareArrowsRounded';
|
||||
import FeaturedPlayListRoundedIcon from '@material-ui/icons/FeaturedPlayListRounded';
|
||||
import KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown';
|
||||
import CheckRoundedIcon from '@material-ui/icons/CheckRounded';
|
||||
import { makeStyles } from '@material-ui/styles';
|
||||
|
||||
import { DefaultButton, PgButtonGroup, PgIconButton, PrimaryButton } from '../../../../../static/js/components/Buttons';
|
||||
import { FilterIcon } from '../../../../../static/js/components/ExternalIcon';
|
||||
import { PgMenu, PgMenuItem, usePgMenuGroup } from '../../../../../static/js/components/Menu';
|
||||
import { FILTER_NAME, MENUS, MENUS_COMPARE_CONSTANT, SCHEMA_DIFF_EVENT } from '../SchemaDiffConstants';
|
||||
import { FILTER_NAME, MENUS, MENUS_COMPARE_CONSTANT, SCHEMA_DIFF_EVENT, IGNORE_OPTION } from '../SchemaDiffConstants';
|
||||
import { SchemaDiffContext, SchemaDiffEventsContext } from './SchemaDiffComponent';
|
||||
|
||||
|
||||
@@ -85,7 +84,11 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI
|
||||
useEffect(() => {
|
||||
let isDisableComp = true;
|
||||
if (sourceData.sid != null && sourceData.did != null && targetData.sid != null && targetData.did != null) {
|
||||
isDisableComp = false;
|
||||
if ((sourceData.scid != null && targetData.scid == null) || (sourceData.scid == null && targetData.scid != null)) {
|
||||
isDisableComp = true;
|
||||
} else {
|
||||
isDisableComp = false;
|
||||
}
|
||||
}
|
||||
setIsDisableCompare(isDisableComp);
|
||||
}, [sourceData, targetData]);
|
||||
@@ -96,10 +99,14 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI
|
||||
if (!_.isUndefined(compareParams)) {
|
||||
compareParams.ignoreOwner && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER);
|
||||
compareParams.ignoreWhitespaces && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE);
|
||||
compareParams.ignoreTablespace && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_TABLESPACE);
|
||||
compareParams.ignoreGrants && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_GRANTS);
|
||||
setSelectedCompare(prefCompareOptions);
|
||||
} else {
|
||||
schemaDiffCtx?.preferences_schema_diff?.ignore_owner && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER);
|
||||
schemaDiffCtx?.preferences_schema_diff?.ignore_whitespaces && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE);
|
||||
schemaDiffCtx?.preferences_schema_diff?.ignore_tablespace && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_TABLESPACE);
|
||||
schemaDiffCtx?.preferences_schema_diff?.ignore_grants && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_GRANTS);
|
||||
setSelectedCompare(prefCompareOptions);
|
||||
}
|
||||
}, [schemaDiffCtx.preferences_schema_diff]);
|
||||
@@ -140,6 +147,8 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI
|
||||
let compareParam = {
|
||||
'ignoreOwner': selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER) ? 1 : 0,
|
||||
'ignoreWhitespaces': selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE) ? 1 : 0,
|
||||
'ignoreTablespace': selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_TABLESPACE) ? 1 : 0,
|
||||
'ignoreGrants': selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_GRANTS) ? 1 : 0,
|
||||
};
|
||||
let filterParam = selectedFilters;
|
||||
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_COMPARE_DIFF, { sourceData, targetData, compareParams: compareParam, filterParams: filterParam });
|
||||
@@ -182,32 +191,32 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI
|
||||
open={openMenuName == MENUS.COMPARE}
|
||||
onClose={onMenuClose}
|
||||
label={gettext('Compare')}
|
||||
align="end"
|
||||
>
|
||||
<PgMenuItem onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER); }}>
|
||||
{selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>}{gettext('Ignore owner')}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE); }}>
|
||||
{selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>}{gettext('Ignore whitespace')}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER)}
|
||||
onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER); }}>{IGNORE_OPTION.OWNER}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE)}
|
||||
onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE); }}>{IGNORE_OPTION.WHITESPACE}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_TABLESPACE)}
|
||||
onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_TABLESPACE); }}>{IGNORE_OPTION.TABLESPACE}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_GRANTS)}
|
||||
onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_GRANTS); }}>{IGNORE_OPTION.GRANTS}</PgMenuItem>
|
||||
</PgMenu>
|
||||
<PgMenu
|
||||
anchorRef={filterRef}
|
||||
open={openMenuName == MENUS.FILTER}
|
||||
onClose={onMenuClose}
|
||||
label={gettext('Filter')}
|
||||
align="end"
|
||||
>
|
||||
<PgMenuItem onClick={() => { selectFilterOption(FILTER_NAME.IDENTICAL); }}>
|
||||
{selectedFilters.includes(FILTER_NAME.IDENTICAL) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>} {gettext(FILTER_NAME.IDENTICAL)}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem onClick={() => { selectFilterOption(FILTER_NAME.DIFFERENT); }}>
|
||||
{selectedFilters.includes(FILTER_NAME.DIFFERENT) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>} {gettext(FILTER_NAME.DIFFERENT)}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem onClick={() => { selectFilterOption(FILTER_NAME.SOURCE_ONLY); }}>
|
||||
{selectedFilters.includes(FILTER_NAME.SOURCE_ONLY) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>} {gettext(FILTER_NAME.SOURCE_ONLY)}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem onClick={() => { selectFilterOption(FILTER_NAME.TARGET_ONLY); }}>
|
||||
{selectedFilters.includes(FILTER_NAME.TARGET_ONLY) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>} {gettext(FILTER_NAME.TARGET_ONLY)}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedFilters.includes(FILTER_NAME.IDENTICAL)}
|
||||
onClick={() => { selectFilterOption(FILTER_NAME.IDENTICAL); }}>{FILTER_NAME.IDENTICAL}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedFilters.includes(FILTER_NAME.DIFFERENT)}
|
||||
onClick={() => { selectFilterOption(FILTER_NAME.DIFFERENT); }}>{FILTER_NAME.DIFFERENT}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedFilters.includes(FILTER_NAME.SOURCE_ONLY)}
|
||||
onClick={() => { selectFilterOption(FILTER_NAME.SOURCE_ONLY); }}>{FILTER_NAME.SOURCE_ONLY}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedFilters.includes(FILTER_NAME.TARGET_ONLY)}
|
||||
onClick={() => { selectFilterOption(FILTER_NAME.TARGET_ONLY); }}>{FILTER_NAME.TARGET_ONLY}</PgMenuItem>
|
||||
</PgMenu>
|
||||
</>
|
||||
);
|
||||
|
@@ -256,8 +256,6 @@ export function SchemaDiffCompare({ params }) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
const triggerSelectSchema = ({ selectedSC, diff_type }) => {
|
||||
@@ -272,7 +270,17 @@ export function SchemaDiffCompare({ params }) {
|
||||
const triggerCompareDiff = async ({ sourceData, targetData, compareParams, filterParams }) => {
|
||||
setGridData([]);
|
||||
setIsInit(false);
|
||||
if (JSON.stringify(sourceData) === JSON.stringify(targetData)) {
|
||||
|
||||
let raiseSelectionError = false;
|
||||
if (!_.isEmpty(sourceData.scid) && !_.isEmpty(targetData.scid)) {
|
||||
if (sourceData.sid === targetData.sid && sourceData.did === targetData.did && sourceData.scid === targetData.scid) {
|
||||
raiseSelectionError = true;
|
||||
}
|
||||
} else if (sourceData.sid === targetData.sid && sourceData.did === targetData.did) {
|
||||
raiseSelectionError = true;
|
||||
}
|
||||
|
||||
if (raiseSelectionError) {
|
||||
Notifier.alert(gettext('Selection Error'),
|
||||
gettext('Please select the different source and target.'));
|
||||
} else {
|
||||
@@ -285,6 +293,8 @@ export function SchemaDiffCompare({ params }) {
|
||||
'target_did': targetData['did'],
|
||||
'ignore_owner': compareParams['ignoreOwner'],
|
||||
'ignore_whitespaces': compareParams['ignoreWhitespaces'],
|
||||
'ignore_tablespace': compareParams['ignoreTablespace'],
|
||||
'ignore_grants': compareParams['ignoreGrants'],
|
||||
};
|
||||
let socketEndpoint = 'compare_database';
|
||||
if (sourceData['scid'] != null && targetData['scid'] != null) {
|
||||
@@ -299,7 +309,7 @@ export function SchemaDiffCompare({ params }) {
|
||||
socket = await openSocket('/schema_diff');
|
||||
socket.on('compare_status', res=>{
|
||||
let msg = res.compare_msg;
|
||||
msg = msg + gettext(` (this may take a few minutes)... ${res.diff_percentage} %`);
|
||||
msg = msg + gettext(` (this may take a few minutes)... ${Math.round(res.diff_percentage)} %`);
|
||||
setLoaderText(msg);
|
||||
});
|
||||
resData = await socketApiGet(socket, socketEndpoint, url_params);
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -413,7 +413,7 @@ CREATE VIEW test_schema_diff."test view" AS
|
||||
pg_class.relacl,
|
||||
pg_class.reloptions,
|
||||
pg_class.relpartbound
|
||||
FROM pg_class
|
||||
FROM pg_catalog.pg_class
|
||||
LIMIT 10;
|
||||
|
||||
|
||||
@@ -1117,7 +1117,7 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping;
|
||||
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping
|
||||
OPTIONS (password 'admin123');
|
||||
|
||||
-- Publication Script
|
||||
-- Publication scripts
|
||||
|
||||
CREATE TABLE test_schema_diff.table_for_publication (
|
||||
col1 integer NOT NULL,
|
||||
@@ -1158,4 +1158,3 @@ ALTER SUBSCRIPTION subscription_test1
|
||||
RENAME TO subscription_test;
|
||||
|
||||
DROP SUBSCRIPTION subscription_test;
|
||||
|
||||
|
@@ -363,7 +363,6 @@ CREATE RULE rule3 AS
|
||||
|
||||
REFRESH MATERIALIZED VIEW test_schema_diff."MView";
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12284 (class 1259 OID 347823)
|
||||
-- Name: test view; Type: VIEW; Schema: test_schema_diff; Owner: postgres
|
||||
@@ -402,7 +401,7 @@ CREATE VIEW test_schema_diff."test view" AS
|
||||
pg_class.relacl,
|
||||
pg_class.reloptions,
|
||||
pg_class.relpartbound
|
||||
FROM pg_class
|
||||
FROM pg_catalog.pg_class
|
||||
LIMIT 10;
|
||||
|
||||
|
||||
@@ -1108,4 +1107,3 @@ ALTER SUBSCRIPTION subscription_test1_in_target
|
||||
RENAME TO subscription_test_in_target;
|
||||
|
||||
DROP SUBSCRIPTION subscription_test_in_target;
|
||||
|
||||
|
@@ -1051,6 +1051,8 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping
|
||||
|
||||
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping;
|
||||
|
||||
-- Publication scripts
|
||||
|
||||
CREATE TABLE test_schema_diff.table_for_publication (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@ SET default_tablespace = '';
|
||||
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA test_schema_diff;
|
||||
SCHEMA test_schema_diff;
|
||||
|
||||
--
|
||||
-- TOC entry 12272 (class 1259 OID 149205)
|
||||
@@ -937,6 +937,7 @@ TABLESPACE pg_default;
|
||||
ALTER TABLE public.test_table_for_foreign_table
|
||||
OWNER to enterprisedb;
|
||||
|
||||
-- Foreign Table scripts
|
||||
CREATE FOREIGN TABLE test_schema_diff.ft_src(
|
||||
fid bigint NULL,
|
||||
fname text NULL COLLATE pg_catalog."default"
|
||||
|
@@ -1213,7 +1213,7 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping
|
||||
|
||||
CREATE USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping;
|
||||
|
||||
-- Publication script
|
||||
-- Publication scripts
|
||||
|
||||
CREATE TABLE test_schema_diff.table_for_publication (
|
||||
col1 integer NOT NULL,
|
||||
|
@@ -117,7 +117,9 @@ class SchemaDiffTestCase(BaseSocketTestGenerator):
|
||||
'target_sid': self.server_id,
|
||||
'target_did': self.tar_db_id,
|
||||
'ignore_owner': 0,
|
||||
'ignore_whitespaces': 0
|
||||
'ignore_whitespaces': 0,
|
||||
'ignore_tablespace': 0,
|
||||
'ignore_grants': 0
|
||||
}
|
||||
self.socket_client.emit('compare_database', data,
|
||||
namespace=self.SOCKET_NAMESPACE)
|
||||
|
Reference in New Issue
Block a user