mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 21:56:00 +00:00
mark view as deleted
This commit is contained in:
@@ -53,6 +53,20 @@ function checkStructure(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const expectedView of expected.views) {
|
||||||
|
const realView = structure.views.find(x => x.pureName == expectedView.pureName);
|
||||||
|
expect(realView).toBeTruthy();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const realView of structure.views) {
|
||||||
|
const expectedView = expected.views.find(x => x.pureName == realView.pureName);
|
||||||
|
if (!expectedView) {
|
||||||
|
if (disallowExtraObjects) {
|
||||||
|
expect(realView).toBeFalsy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testDatabaseDeploy(engine, conn, driver, dbModelsYaml, options) {
|
async function testDatabaseDeploy(engine, conn, driver, dbModelsYaml, options) {
|
||||||
@@ -491,10 +505,91 @@ describe('Deploy database', () => {
|
|||||||
[],
|
[],
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
checkRenameDeletedObjects: true,
|
|
||||||
dbdiffOptionsExtra: {
|
dbdiffOptionsExtra: {
|
||||||
allowTableMarkDropped: true,
|
allowTableMarkDropped: true,
|
||||||
|
allowSqlObjectMarkDropped: true,
|
||||||
|
allowColumnMarkDropped: true,
|
||||||
},
|
},
|
||||||
|
finalCheckAgainstModel: [
|
||||||
|
{
|
||||||
|
name: 't1.table.yaml',
|
||||||
|
json: {
|
||||||
|
name: '_deleted_t1',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'int' },
|
||||||
|
{ name: 'val', type: 'int' },
|
||||||
|
],
|
||||||
|
primaryKey: ['id'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
test.each(engines.map(engine => [engine.label, engine]))(
|
||||||
|
'Mark view removed - %s',
|
||||||
|
testWrapper(async (conn, driver, engine) => {
|
||||||
|
await testDatabaseDeploy(
|
||||||
|
engine,
|
||||||
|
conn,
|
||||||
|
driver,
|
||||||
|
[
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name: 't1.table.yaml',
|
||||||
|
json: {
|
||||||
|
name: 't1',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'int' },
|
||||||
|
{ name: 'val', type: 'int' },
|
||||||
|
],
|
||||||
|
primaryKey: ['id'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'v1.view.sql',
|
||||||
|
text: 'create view v1 as select * from t1',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name: 't1.table.yaml',
|
||||||
|
json: {
|
||||||
|
name: 't1',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'int' },
|
||||||
|
{ name: 'val', type: 'int' },
|
||||||
|
],
|
||||||
|
primaryKey: ['id'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
{
|
||||||
|
dbdiffOptionsExtra: {
|
||||||
|
allowTableMarkDropped: true,
|
||||||
|
allowSqlObjectMarkDropped: true,
|
||||||
|
allowColumnMarkDropped: true,
|
||||||
|
},
|
||||||
|
finalCheckAgainstModel: [
|
||||||
|
{
|
||||||
|
name: 't1.table.yaml',
|
||||||
|
json: {
|
||||||
|
name: 't1',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'int' },
|
||||||
|
{ name: 'val', type: 'int' },
|
||||||
|
],
|
||||||
|
primaryKey: ['id'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '_deleted_v1.view.sql',
|
||||||
|
text: 'create view v1 as select * from t1',
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -583,7 +583,7 @@ export function createAlterDatabasePlan(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (newobj == null) {
|
if (newobj == null) {
|
||||||
if (opts.allowSqlObjectMarkDropped) {
|
if (opts.allowSqlObjectMarkDropped && driver.dialect.renameSqlObject) {
|
||||||
plan.renameSqlObject(oldobj, '_deleted_' + oldobj.pureName);
|
plan.renameSqlObject(oldobj, '_deleted_' + oldobj.pureName);
|
||||||
} else if (!opts.noDropSqlObject) {
|
} else if (!opts.noDropSqlObject) {
|
||||||
plan.dropSqlObject(oldobj);
|
plan.dropSqlObject(oldobj);
|
||||||
|
|||||||
Reference in New Issue
Block a user