1) Added support for unique keys in ERD. Fixes #7249

2) Fixed an issue where foreign key relationships do not update when the primary key is modified. Fixes #7197
This commit is contained in:
Aditya Toshniwal
2022-03-28 16:26:43 +05:30
committed by Akshay Joshi
parent 9f992a9e5d
commit 903b300b9e
9 changed files with 84 additions and 56 deletions

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#cbe7f6;}.cls-1,.cls-2{stroke:#2c66bd;stroke-linecap:round;stroke-linejoin:round;stroke-width:0.75px;}.cls-2{font-size:8px;fill:#2c66bd;font-family:Georgia, Georgia;}</style></defs><title>unique_constraint</title><g id="_2" data-name="2"><circle class="cls-1" cx="8" cy="8" r="5.4"/><text class="cls-2" transform="translate(6.28 10.17)">1</text></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="20" height="20"><defs><style>.cls-1{fill:#cbe7f6;}.cls-1,.cls-2{stroke:#2c66bd;stroke-linecap:round;stroke-linejoin:round;stroke-width:0.75px;}.cls-2{font-size:8px;fill:#2c66bd;font-family:Georgia, Georgia;}</style></defs><title>unique_constraint</title><g id="_2" data-name="2"><circle class="cls-1" cx="8" cy="8" r="5.4"/><text class="cls-2" transform="translate(6.28 10.17)">1</text></g></svg>

Before

Width:  |  Height:  |  Size: 440 B

After

Width:  |  Height:  |  Size: 464 B

View File

@@ -87,8 +87,8 @@ export class ConstraintsSchema extends BaseUISchema {
changeColumnOptions(colOptions) {
this.primaryKeyObj.changeColumnOptions(colOptions);
this.fkObj.changeColumnOptions(colOptions);
this.uniqueConsObj.changeColumnOptions(colOptions);
if(!this.inErd) {
this.uniqueConsObj.changeColumnOptions(colOptions);
this.exConsObj.changeColumnOptions(colOptions);
}
}
@@ -163,7 +163,7 @@ export class ConstraintsSchema extends BaseUISchema {
columns : ['name', 'consrc'],
disabled: this.inCatalog,
},{
id: 'unique_group', type: 'group', label: gettext('Unique'), visible: !this.inErd,
id: 'unique_group', type: 'group', label: gettext('Unique'),
},{
id: 'unique_constraint', label: '',
schema: this.uniqueConsObj,
@@ -338,7 +338,7 @@ export default class TableSchema extends BaseUISchema {
const SUPPORTED_KEYS = [
'name', 'schema', 'description', 'rlspolicy', 'forcerlspolicy', 'fillfactor',
'toast_tuple_target', 'parallel_workers', 'relhasoids', 'relpersistence',
'columns', 'primary_key', 'foreign_key',
'columns', 'primary_key', 'foreign_key', 'unique_constraint',
];
newData = _.pick(newData, SUPPORTED_KEYS);
@@ -975,7 +975,7 @@ export default class TableSchema extends BaseUISchema {
id: 'seclabels', label: gettext('Security labels'), canEdit: false,
schema: new SecLabelSchema(), editable: false, canAdd: true,
type: 'collection', min_version: 90100, mode: ['edit', 'create'],
group: 'security_group', canDelete: true, control: 'unique-col-collection',
group: 'security_group', canDelete: true,
},{
id: 'vacuum_settings_str', label: gettext('Storage settings'),
type: 'multiline', group: 'advanced', mode: ['properties'],