mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 06:26:00 +00:00
db sync fixes
This commit is contained in:
@@ -54,6 +54,7 @@ module.exports = {
|
|||||||
.filter(name => name.endsWith(ext))
|
.filter(name => name.endsWith(ext))
|
||||||
.map(name => ({
|
.map(name => ({
|
||||||
name: name.slice(0, -ext.length),
|
name: name.slice(0, -ext.length),
|
||||||
|
label: path.parse(name.slice(0, -ext.length)).base,
|
||||||
type,
|
type,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ async function importDbModel(inputDir) {
|
|||||||
const text = await fs.readFile(path.join(dir, name), { encoding: 'utf-8' });
|
const text = await fs.readFile(path.join(dir, name), { encoding: 'utf-8' });
|
||||||
|
|
||||||
files.push({
|
files.push({
|
||||||
name,
|
name: path.parse(name).base,
|
||||||
text,
|
text,
|
||||||
json: name.endsWith('.yaml') ? yaml.load(text) : null,
|
json: name.endsWith('.yaml') ? yaml.load(text) : null,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ export class AlterPlan {
|
|||||||
|
|
||||||
_getDependendColumnConstraints(column: ColumnInfo, dependencyDefinition) {
|
_getDependendColumnConstraints(column: ColumnInfo, dependencyDefinition) {
|
||||||
const table = this.db.tables.find(x => x.pureName == column.pureName && x.schemaName == column.schemaName);
|
const table = this.db.tables.find(x => x.pureName == column.pureName && x.schemaName == column.schemaName);
|
||||||
|
if (!table) return [];
|
||||||
const fks = dependencyDefinition?.includes('dependencies')
|
const fks = dependencyDefinition?.includes('dependencies')
|
||||||
? table.dependencies.filter(fk => fk.columns.find(col => col.refColumnName == column.columnName))
|
? table.dependencies.filter(fk => fk.columns.find(col => col.refColumnName == column.columnName))
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -178,7 +178,7 @@
|
|||||||
<AppObjectCore
|
<AppObjectCore
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
{data}
|
{data}
|
||||||
title={data.fileName}
|
title={data.fileLabel}
|
||||||
icon={ARCHIVE_ICONS[data.fileType]}
|
icon={ARCHIVE_ICONS[data.fileType]}
|
||||||
menu={createMenu}
|
menu={createMenu}
|
||||||
on:click={handleClick}
|
on:click={handleClick}
|
||||||
|
|||||||
@@ -80,6 +80,24 @@ await dbgateApi.deployDb(${JSON.stringify(
|
|||||||
newQuery({ initialData: resp.data.sql });
|
newQuery({ initialData: resp.data.sql });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCompareWithCurrentDb = () => {
|
||||||
|
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() {
|
function createMenu() {
|
||||||
return [
|
return [
|
||||||
data.name != 'default' && { text: 'Delete', onClick: handleDelete },
|
data.name != 'default' && { text: 'Delete', onClick: handleDelete },
|
||||||
@@ -89,6 +107,12 @@ await dbgateApi.deployDb(${JSON.stringify(
|
|||||||
{ text: 'Generate deploy DB SQL', onClick: handleGenerateDeploySql },
|
{ text: 'Generate deploy DB SQL', onClick: handleGenerateDeploySql },
|
||||||
{ text: 'Shell: Deploy DB', onClick: handleGenerateDeployScript },
|
{ text: 'Shell: Deploy DB', onClick: handleGenerateDeployScript },
|
||||||
],
|
],
|
||||||
|
|
||||||
|
data.name != 'default' &&
|
||||||
|
_.get($currentDatabase, 'connection._id') && {
|
||||||
|
onClick: handleCompareWithCurrentDb,
|
||||||
|
text: `Compare with ${_.get($currentDatabase, 'name')}`,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
jsonl: 'JSON table data',
|
jsonl: 'JSON table data',
|
||||||
'table.yaml': 'Tables',
|
'table.yaml': 'Tables',
|
||||||
'view.sql': 'Views',
|
'view.sql': 'Views',
|
||||||
'proce.sql': 'Procedures',
|
'proc.sql': 'Procedures',
|
||||||
'func.sql': 'Functions',
|
'func.sql': 'Functions',
|
||||||
'trigger.sql': 'Triggers',
|
'trigger.sql': 'Triggers',
|
||||||
'matview.sql': 'Materialized views',
|
'matview.sql': 'Materialized views',
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
fileName: file.name,
|
fileName: file.name,
|
||||||
folderName: folder,
|
folderName: folder,
|
||||||
fileType: file.type,
|
fileType: file.type,
|
||||||
|
fileLabel: file.label,
|
||||||
}))}
|
}))}
|
||||||
groupFunc={data => ARCHIVE_LABELS[data.fileType] || 'Archive'}
|
groupFunc={data => ARCHIVE_LABELS[data.fileType] || 'Archive'}
|
||||||
module={archiveFileAppObject}
|
module={archiveFileAppObject}
|
||||||
|
|||||||
Reference in New Issue
Block a user