sasat 0.19.42 → 0.19.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli/console.d.ts
CHANGED
package/lib/cli/console.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
+
import * as console from 'console';
|
|
2
3
|
export const Console = {
|
|
3
4
|
success: (msg) => {
|
|
4
5
|
console.log(chalk.green(msg));
|
|
@@ -9,4 +10,7 @@ export const Console = {
|
|
|
9
10
|
log: (msg) => {
|
|
10
11
|
console.log(msg);
|
|
11
12
|
},
|
|
13
|
+
debug: (msg) => {
|
|
14
|
+
console.debug('debug:: ' + msg);
|
|
15
|
+
},
|
|
12
16
|
};
|
|
@@ -2,6 +2,8 @@ import { config } from '../../config/config.js';
|
|
|
2
2
|
import { getDbClient } from '../../db/getDbClient.js';
|
|
3
3
|
import { getMigrationFileNames } from './getMigrationFiles.js';
|
|
4
4
|
import { Console } from '../../cli/console.js';
|
|
5
|
+
import { SqlString } from 'runtime/sql/sqlString';
|
|
6
|
+
import * as console from 'console';
|
|
5
7
|
export var Direction;
|
|
6
8
|
(function (Direction) {
|
|
7
9
|
Direction["Up"] = "up";
|
|
@@ -21,7 +23,7 @@ const calcRunMigrationFileNames = (records) => {
|
|
|
21
23
|
return result;
|
|
22
24
|
};
|
|
23
25
|
export const getCurrentMigration = async (options) => {
|
|
24
|
-
const migrationTable = config().migration.table;
|
|
26
|
+
const migrationTable = SqlString.escapeId(config().migration.table);
|
|
25
27
|
const files = getMigrationFileNames();
|
|
26
28
|
const client = getDbClient();
|
|
27
29
|
const query = `CREATE TABLE IF NOT EXISTS ${migrationTable} ` +
|
|
@@ -32,9 +34,12 @@ export const getCurrentMigration = async (options) => {
|
|
|
32
34
|
Console.log(query);
|
|
33
35
|
}
|
|
34
36
|
await client.rawQuery(query);
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
const q = `SELECT name, direction FROM ${migrationTable} ORDER BY id ASC`;
|
|
38
|
+
if (!options.silent) {
|
|
39
|
+
Console.debug(q);
|
|
40
|
+
}
|
|
41
|
+
const result = await client.rawQuery(q);
|
|
42
|
+
console.debug(result);
|
|
38
43
|
if (!result.length)
|
|
39
44
|
return;
|
|
40
45
|
const runs = calcRunMigrationFileNames(result);
|