diff --git a/packages/api/src/controllers/archive.js b/packages/api/src/controllers/archive.js index 9b367123..44f02204 100644 --- a/packages/api/src/controllers/archive.js +++ b/packages/api/src/controllers/archive.js @@ -54,6 +54,7 @@ module.exports = { .filter(name => name.endsWith(ext)) .map(name => ({ name: name.slice(0, -ext.length), + label: path.parse(name.slice(0, -ext.length)).base, type, })); } diff --git a/packages/api/src/utility/importDbModel.js b/packages/api/src/utility/importDbModel.js index f0030eaf..655fe6ac 100644 --- a/packages/api/src/utility/importDbModel.js +++ b/packages/api/src/utility/importDbModel.js @@ -16,7 +16,7 @@ async function importDbModel(inputDir) { const text = await fs.readFile(path.join(dir, name), { encoding: 'utf-8' }); files.push({ - name, + name: path.parse(name).base, text, json: name.endsWith('.yaml') ? yaml.load(text) : null, }); diff --git a/packages/tools/src/alterPlan.ts b/packages/tools/src/alterPlan.ts index e915cac7..eea0f295 100644 --- a/packages/tools/src/alterPlan.ts +++ b/packages/tools/src/alterPlan.ts @@ -226,6 +226,7 @@ export class AlterPlan { _getDependendColumnConstraints(column: ColumnInfo, dependencyDefinition) { const table = this.db.tables.find(x => x.pureName == column.pureName && x.schemaName == column.schemaName); + if (!table) return []; const fks = dependencyDefinition?.includes('dependencies') ? table.dependencies.filter(fk => fk.columns.find(col => col.refColumnName == column.columnName)) : []; diff --git a/packages/web/src/appobj/ArchiveFileAppObject.svelte b/packages/web/src/appobj/ArchiveFileAppObject.svelte index 849bb4f3..1452811b 100644 --- a/packages/web/src/appobj/ArchiveFileAppObject.svelte +++ b/packages/web/src/appobj/ArchiveFileAppObject.svelte @@ -178,7 +178,7 @@ { + openNewTab( + { + title: 'Compare', + icon: 'img compare', + tabComponent: 'CompareModelTab', + }, + { + editor: { + sourceConid: '__model', + sourceDatabase: `archive:${data.name}`, + targetConid: _.get($currentDatabase, 'connection._id'), + targetDatabase: _.get($currentDatabase, 'name'), + }, + } + ); + }; + function createMenu() { return [ data.name != 'default' && { text: 'Delete', onClick: handleDelete }, @@ -89,6 +107,12 @@ await dbgateApi.deployDb(${JSON.stringify( { text: 'Generate deploy DB SQL', onClick: handleGenerateDeploySql }, { text: 'Shell: Deploy DB', onClick: handleGenerateDeployScript }, ], + + data.name != 'default' && + _.get($currentDatabase, 'connection._id') && { + onClick: handleCompareWithCurrentDb, + text: `Compare with ${_.get($currentDatabase, 'name')}`, + }, ]; } diff --git a/packages/web/src/widgets/ArchiveFilesList.svelte b/packages/web/src/widgets/ArchiveFilesList.svelte index 7847fb2d..cca2340a 100644 --- a/packages/web/src/widgets/ArchiveFilesList.svelte +++ b/packages/web/src/widgets/ArchiveFilesList.svelte @@ -3,7 +3,7 @@ jsonl: 'JSON table data', 'table.yaml': 'Tables', 'view.sql': 'Views', - 'proce.sql': 'Procedures', + 'proc.sql': 'Procedures', 'func.sql': 'Functions', 'trigger.sql': 'Triggers', 'matview.sql': 'Materialized views', @@ -45,6 +45,7 @@ fileName: file.name, folderName: folder, fileType: file.type, + fileLabel: file.label, }))} groupFunc={data => ARCHIVE_LABELS[data.fileType] || 'Archive'} module={archiveFileAppObject}