mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 01:25:59 +00:00
added run_count to script driver deployer
This commit is contained in:
@@ -671,6 +671,15 @@ describe('Deploy database', () => {
|
||||
|
||||
const res3 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM dbgate_deploy_journal');
|
||||
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'");
|
||||
expect(res4.rows[0].run_count == 1).toBeTruthy();
|
||||
|
||||
const res5 = await driver.query(
|
||||
conn,
|
||||
"SELECT run_count from dbgate_deploy_journal where name = 't1.install.sql'"
|
||||
);
|
||||
expect(res5.rows[0].run_count == 2).toBeTruthy();
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -57,9 +57,10 @@ export class ScriptDrivedDeployer {
|
||||
{ columnName: 'id', dataType: 'int', autoIncrement: true, notNull: true, pureName: 'dbgate_deploy_journal' },
|
||||
{ columnName: 'name', dataType: 'varchar(100)', notNull: true, pureName: 'dbgate_deploy_journal' },
|
||||
{ columnName: 'category', dataType: 'varchar(100)', notNull: true, pureName: 'dbgate_deploy_journal' },
|
||||
{ columnName: 'script_hash', dataType: 'varchar(100)', notNull: true, pureName: 'dbgate_deploy_journal' },
|
||||
{ columnName: 'first_run_date', dataType: 'varchar(100)', notNull: true, pureName: 'dbgate_deploy_journal' },
|
||||
{ columnName: 'last_run_date', dataType: 'varchar(100)', notNull: true, pureName: 'dbgate_deploy_journal' },
|
||||
{ columnName: 'script_hash', dataType: 'varchar(100)', notNull: true, pureName: 'dbgate_deploy_journal' },
|
||||
{ columnName: 'run_count', dataType: 'int', notNull: true, pureName: 'dbgate_deploy_journal' },
|
||||
],
|
||||
foreignKeys: [],
|
||||
primaryKey: {
|
||||
@@ -101,7 +102,7 @@ export class ScriptDrivedDeployer {
|
||||
if (existing) {
|
||||
await runCommandOnDriver(this.dbhan, this.driver, dmp => {
|
||||
dmp.put(
|
||||
'update ~dbgate_deploy_journal set ~last_run_date = %v, ~script_hash = %v where ~id = %v',
|
||||
'update ~dbgate_deploy_journal set ~last_run_date = %v, ~script_hash = %v, ~run_count = ~run_count + 1 where ~id = %v',
|
||||
new Date().toISOString(),
|
||||
hash,
|
||||
existing.id
|
||||
@@ -110,7 +111,7 @@ export class ScriptDrivedDeployer {
|
||||
} else {
|
||||
await runCommandOnDriver(this.dbhan, this.driver, dmp => {
|
||||
dmp.put(
|
||||
'insert into ~dbgate_deploy_journal (~name, ~category, ~first_run_date, ~last_run_date, ~script_hash) values (%v, %v, %v, %v, %v)',
|
||||
'insert into ~dbgate_deploy_journal (~name, ~category, ~first_run_date, ~last_run_date, ~script_hash, ~run_count) values (%v, %v, %v, %v, %v, 1)',
|
||||
file.name,
|
||||
category,
|
||||
new Date().toISOString(),
|
||||
|
||||
Reference in New Issue
Block a user