@sqb/migrator 4.10.3 → 4.10.5
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.
|
@@ -155,8 +155,7 @@ CREATE TABLE IF NOT EXISTS ${adapter.eventTableFull}
|
|
|
155
155
|
script = task.script;
|
|
156
156
|
if (typeof script !== 'string')
|
|
157
157
|
return;
|
|
158
|
-
script = script
|
|
159
|
-
.replace(/(\$\((\w+)\))/g, (s, ...args) => variables[args[1]] || s);
|
|
158
|
+
script = this.replaceVariables(script, variables);
|
|
160
159
|
await this._connection.execute(script);
|
|
161
160
|
}
|
|
162
161
|
catch (e) {
|
|
@@ -180,8 +179,9 @@ CREATE TABLE IF NOT EXISTS ${adapter.eventTableFull}
|
|
|
180
179
|
return;
|
|
181
180
|
}
|
|
182
181
|
if ((0, migration_package_js_1.isInsertDataMigrationTask)(task)) {
|
|
182
|
+
const tableName = this.replaceVariables(task.tableName, variables);
|
|
183
183
|
const script = task.rows
|
|
184
|
-
.map(row => this.rowToSql(
|
|
184
|
+
.map(row => this.rowToSql(tableName, row))
|
|
185
185
|
.join('\n');
|
|
186
186
|
await this._connection.execute(script);
|
|
187
187
|
}
|
package/cjs/migration-adapter.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MigrationAdapter = void 0;
|
|
4
4
|
class MigrationAdapter {
|
|
5
|
+
replaceVariables(text, variables) {
|
|
6
|
+
return text.replace(/(\$\((\w+)\))/g, (s, ...args) => variables[args[1]] || s);
|
|
7
|
+
}
|
|
5
8
|
}
|
|
6
9
|
exports.MigrationAdapter = MigrationAdapter;
|
|
7
10
|
(function (MigrationAdapter) {
|
|
@@ -151,8 +151,7 @@ CREATE TABLE IF NOT EXISTS ${adapter.eventTableFull}
|
|
|
151
151
|
script = task.script;
|
|
152
152
|
if (typeof script !== 'string')
|
|
153
153
|
return;
|
|
154
|
-
script = script
|
|
155
|
-
.replace(/(\$\((\w+)\))/g, (s, ...args) => variables[args[1]] || s);
|
|
154
|
+
script = this.replaceVariables(script, variables);
|
|
156
155
|
await this._connection.execute(script);
|
|
157
156
|
}
|
|
158
157
|
catch (e) {
|
|
@@ -176,8 +175,9 @@ CREATE TABLE IF NOT EXISTS ${adapter.eventTableFull}
|
|
|
176
175
|
return;
|
|
177
176
|
}
|
|
178
177
|
if (isInsertDataMigrationTask(task)) {
|
|
178
|
+
const tableName = this.replaceVariables(task.tableName, variables);
|
|
179
179
|
const script = task.rows
|
|
180
|
-
.map(row => this.rowToSql(
|
|
180
|
+
.map(row => this.rowToSql(tableName, row))
|
|
181
181
|
.join('\n');
|
|
182
182
|
await this._connection.execute(script);
|
|
183
183
|
}
|
package/esm/migration-adapter.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/migrator",
|
|
3
3
|
"description": "Database migrator for SQB",
|
|
4
|
-
"version": "4.10.
|
|
4
|
+
"version": "4.10.5",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"ts-gems": "^2.5.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@sqb/builder": "^4.10.
|
|
40
|
-
"@sqb/connect": "^4.10.
|
|
41
|
-
"@sqb/postgres": "^4.10.
|
|
39
|
+
"@sqb/builder": "^4.10.5",
|
|
40
|
+
"@sqb/connect": "^4.10.5",
|
|
41
|
+
"@sqb/postgres": "^4.10.5"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=16.0",
|
|
@@ -16,6 +16,7 @@ export declare abstract class MigrationAdapter {
|
|
|
16
16
|
abstract unlockSchema(): Promise<void>;
|
|
17
17
|
abstract backupDatabase(): Promise<void>;
|
|
18
18
|
abstract restoreDatabase(): Promise<void>;
|
|
19
|
+
protected replaceVariables(text: string, variables: Record<string, string>): string;
|
|
19
20
|
}
|
|
20
21
|
export declare namespace MigrationAdapter {
|
|
21
22
|
enum EventKind {
|