mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 04:00:59 +00:00
mark view as deleted
This commit is contained in:
parent
81297383cb
commit
2ce20b5fac
@ -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) {
|
||||
@ -491,10 +505,91 @@ describe('Deploy database', () => {
|
||||
[],
|
||||
],
|
||||
{
|
||||
checkRenameDeletedObjects: true,
|
||||
dbdiffOptionsExtra: {
|
||||
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 {
|
||||
if (newobj == null) {
|
||||
if (opts.allowSqlObjectMarkDropped) {
|
||||
if (opts.allowSqlObjectMarkDropped && driver.dialect.renameSqlObject) {
|
||||
plan.renameSqlObject(oldobj, '_deleted_' + oldobj.pureName);
|
||||
} else if (!opts.noDropSqlObject) {
|
||||
plan.dropSqlObject(oldobj);
|
||||
|
Loading…
Reference in New Issue
Block a user