mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 16:26:00 +00:00
try to fix tests
This commit is contained in:
@@ -613,77 +613,77 @@ describe('Deploy database', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// test.each(engines.filter(x => !x.skipDataModifications).map(engine => [engine.label, engine]))(
|
test.each(engines.filter(x => !x.skipDataModifications).map(engine => [engine.label, engine]))(
|
||||||
// 'Script drived deploy - basic predeploy - %s',
|
'Script drived deploy - basic predeploy - %s',
|
||||||
// testWrapper(async (conn, driver, engine) => {
|
testWrapper(async (conn, driver, engine) => {
|
||||||
// await testDatabaseDeploy(engine, conn, driver, [
|
await testDatabaseDeploy(engine, conn, driver, [
|
||||||
// [
|
[
|
||||||
// {
|
{
|
||||||
// name: '1.predeploy.sql',
|
name: '1.predeploy.sql',
|
||||||
// text: 'create table t1 (id int primary key); insert into t1 (id) values (1);',
|
text: 'create table t1 (id int primary key); insert into t1 (id) values (1);',
|
||||||
// },
|
},
|
||||||
// ],
|
],
|
||||||
// ]);
|
]);
|
||||||
|
|
||||||
// const res1 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM t1');
|
const res1 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM t1');
|
||||||
// expect(res1.rows[0].cnt == 1).toBeTruthy();
|
expect(res1.rows[0].cnt == 1).toBeTruthy();
|
||||||
|
|
||||||
// const res2 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM dbgate_deploy_journal');
|
const res2 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM dbgate_deploy_journal');
|
||||||
// expect(res2.rows[0].cnt == 1).toBeTruthy();
|
expect(res2.rows[0].cnt == 1).toBeTruthy();
|
||||||
// })
|
})
|
||||||
// );
|
);
|
||||||
|
|
||||||
// test.each(engines.filter(x => !x.skipDataModifications).map(engine => [engine.label, engine]))(
|
test.each(engines.filter(x => !x.skipDataModifications).map(engine => [engine.label, engine]))(
|
||||||
// 'Script drived deploy - install+uninstall - %s',
|
'Script drived deploy - install+uninstall - %s',
|
||||||
// testWrapper(async (conn, driver, engine) => {
|
testWrapper(async (conn, driver, engine) => {
|
||||||
// await testDatabaseDeploy(engine, conn, driver, [
|
await testDatabaseDeploy(engine, conn, driver, [
|
||||||
// [
|
[
|
||||||
// {
|
{
|
||||||
// name: 't1.uninstall.sql',
|
name: 't1.uninstall.sql',
|
||||||
// text: 'drop table t1',
|
text: 'drop table t1',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// name: 't1.install.sql',
|
name: 't1.install.sql',
|
||||||
// text: 'create table t1 (id int primary key); insert into t1 (id) values (1)',
|
text: 'create table t1 (id int primary key); insert into t1 (id) values (1)',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// name: 't2.once.sql',
|
name: 't2.once.sql',
|
||||||
// text: 'create table t2 (id int primary key); insert into t2 (id) values (1)',
|
text: 'create table t2 (id int primary key); insert into t2 (id) values (1)',
|
||||||
// },
|
},
|
||||||
// ],
|
],
|
||||||
// [
|
[
|
||||||
// {
|
{
|
||||||
// name: 't1.uninstall.sql',
|
name: 't1.uninstall.sql',
|
||||||
// text: 'drop table t1',
|
text: 'drop table t1',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// name: 't1.install.sql',
|
name: 't1.install.sql',
|
||||||
// text: 'create table t1 (id int primary key, val int); insert into t1 (id, val) values (1, 11)',
|
text: 'create table t1 (id int primary key, val int); insert into t1 (id, val) values (1, 11)',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// name: 't2.once.sql',
|
name: 't2.once.sql',
|
||||||
// text: 'insert into t2 (id) values (2)',
|
text: 'insert into t2 (id) values (2)',
|
||||||
// },
|
},
|
||||||
// ],
|
],
|
||||||
// ]);
|
]);
|
||||||
|
|
||||||
// const res1 = await driver.query(conn, 'SELECT val from t1 where id = 1');
|
const res1 = await driver.query(conn, 'SELECT val from t1 where id = 1');
|
||||||
// expect(res1.rows[0].val == 11).toBeTruthy();
|
expect(res1.rows[0].val == 11).toBeTruthy();
|
||||||
|
|
||||||
// const res2 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM t2');
|
const res2 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM t2');
|
||||||
// expect(res2.rows[0].cnt == 1).toBeTruthy();
|
expect(res2.rows[0].cnt == 1).toBeTruthy();
|
||||||
|
|
||||||
// const res3 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM dbgate_deploy_journal');
|
const res3 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM dbgate_deploy_journal');
|
||||||
// expect(res3.rows[0].cnt == 3).toBeTruthy();
|
expect(res3.rows[0].cnt == 3).toBeTruthy();
|
||||||
|
|
||||||
// const res4 = await driver.query(conn, "SELECT run_count from dbgate_deploy_journal where name = 't2.once.sql'");
|
const res4 = await driver.query(conn, "SELECT run_count from dbgate_deploy_journal where name = 't2.once.sql'");
|
||||||
// expect(res4.rows[0].run_count == 1).toBeTruthy();
|
expect(res4.rows[0].run_count == 1).toBeTruthy();
|
||||||
|
|
||||||
// const res5 = await driver.query(
|
const res5 = await driver.query(
|
||||||
// conn,
|
conn,
|
||||||
// "SELECT run_count from dbgate_deploy_journal where name = 't1.install.sql'"
|
"SELECT run_count from dbgate_deploy_journal where name = 't1.install.sql'"
|
||||||
// );
|
);
|
||||||
// expect(res5.rows[0].run_count == 2).toBeTruthy();
|
expect(res5.rows[0].run_count == 2).toBeTruthy();
|
||||||
// })
|
})
|
||||||
// );
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,28 +17,38 @@ async function deployDb({
|
|||||||
ignoreNameRegex = '',
|
ignoreNameRegex = '',
|
||||||
targetSchema = null,
|
targetSchema = null,
|
||||||
}) {
|
}) {
|
||||||
const dbhan = systemConnection || (await connectUtility(driver, connection, 'read'));
|
|
||||||
if (!driver) driver = requireEngineDriver(connection);
|
if (!driver) driver = requireEngineDriver(connection);
|
||||||
|
const dbhan = systemConnection || (await connectUtility(driver, connection, 'read'));
|
||||||
|
|
||||||
const scriptDeployer = new ScriptDrivedDeployer(dbhan, driver, loadedDbModel ?? (await loadModelFolder(modelFolder)));
|
try {
|
||||||
await scriptDeployer.runPre();
|
const scriptDeployer = new ScriptDrivedDeployer(
|
||||||
|
dbhan,
|
||||||
|
driver,
|
||||||
|
loadedDbModel ?? (await loadModelFolder(modelFolder))
|
||||||
|
);
|
||||||
|
await scriptDeployer.runPre();
|
||||||
|
|
||||||
const { sql } = await generateDeploySql({
|
const { sql } = await generateDeploySql({
|
||||||
connection,
|
connection,
|
||||||
systemConnection: dbhan,
|
systemConnection: dbhan,
|
||||||
driver,
|
driver,
|
||||||
analysedStructure,
|
analysedStructure,
|
||||||
modelFolder,
|
modelFolder,
|
||||||
loadedDbModel,
|
loadedDbModel,
|
||||||
modelTransforms,
|
modelTransforms,
|
||||||
dbdiffOptionsExtra,
|
dbdiffOptionsExtra,
|
||||||
ignoreNameRegex,
|
ignoreNameRegex,
|
||||||
targetSchema,
|
targetSchema,
|
||||||
});
|
});
|
||||||
// console.log('RUNNING DEPLOY SCRIPT:', sql);
|
// console.log('RUNNING DEPLOY SCRIPT:', sql);
|
||||||
await executeQuery({ connection, systemConnection: dbhan, driver, sql, logScriptItems: true });
|
await executeQuery({ connection, systemConnection: dbhan, driver, sql, logScriptItems: true });
|
||||||
|
|
||||||
await scriptDeployer.runPost();
|
await scriptDeployer.runPost();
|
||||||
|
} finally {
|
||||||
|
if (!systemConnection) {
|
||||||
|
await driver.close(dbhan);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = deployDb;
|
module.exports = deployDb;
|
||||||
|
|||||||
Reference in New Issue
Block a user