sasat 0.22.8 → 0.22.9
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/dist/cli/index.cjs +23 -5
- package/dist/cli/index.mjs +21 -3
- package/dist/comparison-Bkk-qNRi.d.cts +79 -0
- package/dist/comparison-HpKmxsjs.d.mts +79 -0
- package/dist/index-1a8KLRT7.d.mts +495 -0
- package/dist/index-lrk3IfPF.d.cts +495 -0
- package/dist/index.cjs +25 -829
- package/dist/index.d.cts +3 -495
- package/dist/index.d.mts +3 -495
- package/dist/index.mjs +2 -805
- package/dist/{migrate-mh3DLqgw.mjs → migrate-D-XR7Z0F.mjs} +90 -65
- package/dist/{migrate-COeYPag2.cjs → migrate-iJE4FjRh.cjs} +94 -63
- package/dist/migration/index.d.cts +2 -2
- package/dist/migration/index.d.mts +2 -2
- package/dist/src-CdwAbJV0.cjs +926 -0
- package/dist/src-DebKrtYl.mjs +806 -0
- package/dist/testing/index.cjs +70 -1
- package/dist/testing/index.d.cts +19 -2
- package/dist/testing/index.d.mts +19 -2
- package/dist/testing/index.mjs +69 -2
- package/dist/{util-IRlTD1y7.cjs → util-C5Jevn5B.cjs} +130 -0
- package/dist/{util-BcMcffJ8.mjs → util-Dkw5bD7a.mjs} +107 -1
- package/package.json +1 -1
- package/dist/comparison-CEpYTo3e.d.mts +0 -42
- package/dist/comparison-CIb9xu5T.d.cts +0 -42
- package/dist/dbClient-Bnk1JKBU.d.cts +0 -35
- package/dist/dbClient-TBYnlvTc.d.mts +0 -35
- package/dist/getDbClient-CNcumqpO.mjs +0 -108
- package/dist/getDbClient-Dnkk-peb.cjs +0 -131
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as setConfig, g as writeFileIfNotExist, h as writeCurrentSchema, i as SasatError, l as SqlString, m as readInitialSchema, p as mkDirIfNotExist, r as unique, t as nonNullable, u as config } from "./util-Dkw5bD7a.mjs";
|
|
2
2
|
import { t as Conditions } from "./makeCondition-BQj-Av95.mjs";
|
|
3
3
|
import fs, { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
|
-
import path from "node:path";
|
|
5
|
+
import path, { join } from "node:path";
|
|
6
6
|
import { mkdir, readdir, rm, writeFile } from "node:fs/promises";
|
|
7
7
|
import "pluralize";
|
|
8
8
|
import chalk from "chalk";
|
|
@@ -1015,6 +1015,7 @@ var StoreMigrator = class StoreMigrator {
|
|
|
1015
1015
|
constructor() {
|
|
1016
1016
|
this.tables = [];
|
|
1017
1017
|
this.migrationQueue = [];
|
|
1018
|
+
this.currentOption = { skipOnTest: false };
|
|
1018
1019
|
}
|
|
1019
1020
|
static new() {
|
|
1020
1021
|
if (fs.existsSync(path.join(config().migration.dir, "initialSchema.yml"))) return StoreMigrator.deserialize(readInitialSchema());
|
|
@@ -1155,6 +1156,7 @@ const readMigration = async (store, tsFileName, direction) => {
|
|
|
1155
1156
|
await instance.down(store);
|
|
1156
1157
|
if (instance.afterDown) await instance.afterDown();
|
|
1157
1158
|
}
|
|
1159
|
+
store.currentOption = { skipOnTest: instance.skipOnTest ?? false };
|
|
1158
1160
|
return store;
|
|
1159
1161
|
};
|
|
1160
1162
|
//#endregion
|
|
@@ -1169,6 +1171,88 @@ const createCurrentMigrationDataStore = async (targetMigrationName) => {
|
|
|
1169
1171
|
return store;
|
|
1170
1172
|
};
|
|
1171
1173
|
//#endregion
|
|
1174
|
+
//#region src/migration/exec/getMigrationTarget.ts
|
|
1175
|
+
const getMigrationTargets = (files, current) => {
|
|
1176
|
+
const currentIndex = current ? files.indexOf(current) + 1 : 0;
|
|
1177
|
+
const targetIndex = files.indexOf(config().migration.target || files[files.length - 1]) + 1;
|
|
1178
|
+
if (currentIndex === -1 || targetIndex === -1) throw new Error("migration target not found");
|
|
1179
|
+
if (targetIndex >= currentIndex) return {
|
|
1180
|
+
direction: "up",
|
|
1181
|
+
files: files.slice(currentIndex, targetIndex)
|
|
1182
|
+
};
|
|
1183
|
+
return {
|
|
1184
|
+
direction: "down",
|
|
1185
|
+
files: files.slice(targetIndex, currentIndex).reverse()
|
|
1186
|
+
};
|
|
1187
|
+
};
|
|
1188
|
+
//#endregion
|
|
1189
|
+
//#region src/migration/exec/runMigration.ts
|
|
1190
|
+
const runMigration = async (client, store, migrationName, direction, options) => {
|
|
1191
|
+
const sqls = store.getSql();
|
|
1192
|
+
const conf = store.getUpdateConfig();
|
|
1193
|
+
if (conf) setConfig(conf);
|
|
1194
|
+
store.resetQueue();
|
|
1195
|
+
if (!options.silent) sqls.forEach(Console.log);
|
|
1196
|
+
if (options.dry) return;
|
|
1197
|
+
const transaction = await client.transaction();
|
|
1198
|
+
try {
|
|
1199
|
+
for (const sql of sqls) await transaction.rawQuery(sql).catch((e) => {
|
|
1200
|
+
Console.error(`ERROR ON ${migrationName}`);
|
|
1201
|
+
Console.error(`SQL: ${sql}`);
|
|
1202
|
+
Console.error(`MESSAGE: ${e.message}`);
|
|
1203
|
+
process.exit(1);
|
|
1204
|
+
});
|
|
1205
|
+
await transaction.query`insert into ${() => config().migration.table} (name, direction) values (${[migrationName, direction]})`;
|
|
1206
|
+
return await transaction.commit();
|
|
1207
|
+
} catch (e) {
|
|
1208
|
+
await transaction.rollback();
|
|
1209
|
+
throw e;
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1212
|
+
//#endregion
|
|
1213
|
+
//#region src/migration/controller.ts
|
|
1214
|
+
var MigrationController = class {
|
|
1215
|
+
async migrate(client, currentMigration, options, execute = runMigration) {
|
|
1216
|
+
const fileNames = getMigrationFileNames();
|
|
1217
|
+
if (!options.silent) Console.log("--current migration--: " + currentMigration);
|
|
1218
|
+
let store = await createCurrentMigrationDataStore(currentMigration);
|
|
1219
|
+
if (store.getUpdateConfig()) setConfig(store.getUpdateConfig());
|
|
1220
|
+
const target = getMigrationTargets(fileNames, currentMigration);
|
|
1221
|
+
for (const tsFileName of target.files) {
|
|
1222
|
+
if (!options.silent) Console.log("---------\n" + tsFileName);
|
|
1223
|
+
store = await readMigration(store, tsFileName, target.direction);
|
|
1224
|
+
await execute(client, store, tsFileName, target.direction, options);
|
|
1225
|
+
store.resetQueue();
|
|
1226
|
+
}
|
|
1227
|
+
return {
|
|
1228
|
+
store: store.serialize(),
|
|
1229
|
+
currentMigration: config().migration.target || fileNames[fileNames.length - 1]
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
//#endregion
|
|
1234
|
+
//#region src/cli/commands/generateTestMigrationFile.ts
|
|
1235
|
+
async function generateTestMigrationFile(client) {
|
|
1236
|
+
try {
|
|
1237
|
+
await compileMigrationFiles();
|
|
1238
|
+
const migration = new MigrationController();
|
|
1239
|
+
const sqls = [];
|
|
1240
|
+
const exec = async (_, store) => {
|
|
1241
|
+
if (!store.currentOption.skipOnTest) sqls.push(...store.getSql());
|
|
1242
|
+
};
|
|
1243
|
+
await migration.migrate(client, void 0, {
|
|
1244
|
+
generateFiles: false,
|
|
1245
|
+
silent: true,
|
|
1246
|
+
dry: false,
|
|
1247
|
+
skipBuild: false
|
|
1248
|
+
}, exec);
|
|
1249
|
+
fs.writeFileSync(join(config().migration.dir, "test.migration.json"), JSON.stringify(sqls));
|
|
1250
|
+
} catch (e) {
|
|
1251
|
+
Console.error(e.message);
|
|
1252
|
+
throw e;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
//#endregion
|
|
1172
1256
|
//#region src/generatorv2/fs/emptyDir.ts
|
|
1173
1257
|
async function emptyDir(dir) {
|
|
1174
1258
|
let items;
|
|
@@ -3491,74 +3575,15 @@ var CodeGen_v2 = class {
|
|
|
3491
3575
|
}
|
|
3492
3576
|
};
|
|
3493
3577
|
//#endregion
|
|
3494
|
-
//#region src/migration/exec/getMigrationTarget.ts
|
|
3495
|
-
const getMigrationTargets = (files, current) => {
|
|
3496
|
-
const currentIndex = current ? files.indexOf(current) + 1 : 0;
|
|
3497
|
-
const targetIndex = files.indexOf(config().migration.target || files[files.length - 1]) + 1;
|
|
3498
|
-
if (currentIndex === -1 || targetIndex === -1) throw new Error("migration target not found");
|
|
3499
|
-
if (targetIndex >= currentIndex) return {
|
|
3500
|
-
direction: "up",
|
|
3501
|
-
files: files.slice(currentIndex, targetIndex)
|
|
3502
|
-
};
|
|
3503
|
-
return {
|
|
3504
|
-
direction: "down",
|
|
3505
|
-
files: files.slice(targetIndex, currentIndex).reverse()
|
|
3506
|
-
};
|
|
3507
|
-
};
|
|
3508
|
-
//#endregion
|
|
3509
|
-
//#region src/migration/exec/runMigration.ts
|
|
3510
|
-
const runMigration = async (client, store, migrationName, direction, options) => {
|
|
3511
|
-
const sqls = store.getSql();
|
|
3512
|
-
const conf = store.getUpdateConfig();
|
|
3513
|
-
if (conf) setConfig(conf);
|
|
3514
|
-
store.resetQueue();
|
|
3515
|
-
if (!options.silent) sqls.forEach(Console.log);
|
|
3516
|
-
if (options.dry) return;
|
|
3517
|
-
const transaction = await client.transaction();
|
|
3518
|
-
try {
|
|
3519
|
-
for (const sql of sqls) await transaction.rawQuery(sql).catch((e) => {
|
|
3520
|
-
Console.error(`ERROR ON ${migrationName}`);
|
|
3521
|
-
Console.error(`SQL: ${sql}`);
|
|
3522
|
-
Console.error(`MESSAGE: ${e.message}`);
|
|
3523
|
-
process.exit(1);
|
|
3524
|
-
});
|
|
3525
|
-
await transaction.query`insert into ${() => config().migration.table} (name, direction) values (${[migrationName, direction]})`;
|
|
3526
|
-
return await transaction.commit();
|
|
3527
|
-
} catch (e) {
|
|
3528
|
-
await transaction.rollback();
|
|
3529
|
-
throw e;
|
|
3530
|
-
}
|
|
3531
|
-
};
|
|
3532
|
-
//#endregion
|
|
3533
|
-
//#region src/migration/controller.ts
|
|
3534
|
-
var MigrationController = class {
|
|
3535
|
-
async migrate(client, options) {
|
|
3536
|
-
const fileNames = getMigrationFileNames();
|
|
3537
|
-
const currentMigration = await getCurrentMigration(client, options);
|
|
3538
|
-
if (!options.silent) Console.log("--current migration--: " + currentMigration);
|
|
3539
|
-
let store = await createCurrentMigrationDataStore(currentMigration);
|
|
3540
|
-
if (store.getUpdateConfig()) setConfig(store.getUpdateConfig());
|
|
3541
|
-
const target = getMigrationTargets(fileNames, currentMigration);
|
|
3542
|
-
for (const tsFileName of target.files) {
|
|
3543
|
-
if (!options.silent) Console.log("---------\n" + tsFileName);
|
|
3544
|
-
store = await readMigration(store, tsFileName, target.direction);
|
|
3545
|
-
await runMigration(client, store, tsFileName, target.direction, options);
|
|
3546
|
-
store.resetQueue();
|
|
3547
|
-
}
|
|
3548
|
-
return {
|
|
3549
|
-
store: store.serialize(),
|
|
3550
|
-
currentMigration: config().migration.target || fileNames[fileNames.length - 1]
|
|
3551
|
-
};
|
|
3552
|
-
}
|
|
3553
|
-
};
|
|
3554
|
-
//#endregion
|
|
3555
3578
|
//#region src/cli/commands/migrate.ts
|
|
3556
3579
|
const migrate = async (client, options) => {
|
|
3557
3580
|
let current;
|
|
3558
3581
|
if (!options.silent) Console.log("--migration started--");
|
|
3559
3582
|
try {
|
|
3560
3583
|
if (!options.skipBuild) await compileMigrationFiles();
|
|
3561
|
-
const
|
|
3584
|
+
const migration = new MigrationController();
|
|
3585
|
+
const currentMigration = await getCurrentMigration(client, options);
|
|
3586
|
+
const result = await migration.migrate(client, currentMigration, options);
|
|
3562
3587
|
current = result.currentMigration;
|
|
3563
3588
|
if (options.generateFiles) {
|
|
3564
3589
|
const storeHandler = new DataStoreHandler(result.store);
|
|
@@ -3572,4 +3597,4 @@ const migrate = async (client, options) => {
|
|
|
3572
3597
|
}
|
|
3573
3598
|
};
|
|
3574
3599
|
//#endregion
|
|
3575
|
-
export {
|
|
3600
|
+
export { compileMigrationFiles as a, Directory as c, columnTypeToGqlPrimitive as d, DBColumnTypes as f, capitalizeFirstLetter as h, createCurrentMigrationDataStore as i, defaultColumnOption as l, camelize as m, CodeGen_v2 as n, getMigrationFileNames as o, Console as p, generateTestMigrationFile as r, DataStoreHandler as s, migrate as t, defaultGQLOption as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_util = require("./util-
|
|
1
|
+
const require_util = require("./util-C5Jevn5B.cjs");
|
|
2
2
|
const require_makeCondition = require("./makeCondition-DljWZv_v.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
node_fs = require_util.__toESM(node_fs, 1);
|
|
@@ -1018,6 +1018,7 @@ var StoreMigrator = class StoreMigrator {
|
|
|
1018
1018
|
constructor() {
|
|
1019
1019
|
this.tables = [];
|
|
1020
1020
|
this.migrationQueue = [];
|
|
1021
|
+
this.currentOption = { skipOnTest: false };
|
|
1021
1022
|
}
|
|
1022
1023
|
static new() {
|
|
1023
1024
|
if (node_fs.default.existsSync(node_path.default.join(require_util.config().migration.dir, "initialSchema.yml"))) return StoreMigrator.deserialize(require_util.readInitialSchema());
|
|
@@ -1158,6 +1159,7 @@ const readMigration = async (store, tsFileName, direction) => {
|
|
|
1158
1159
|
await instance.down(store);
|
|
1159
1160
|
if (instance.afterDown) await instance.afterDown();
|
|
1160
1161
|
}
|
|
1162
|
+
store.currentOption = { skipOnTest: instance.skipOnTest ?? false };
|
|
1161
1163
|
return store;
|
|
1162
1164
|
};
|
|
1163
1165
|
//#endregion
|
|
@@ -1172,6 +1174,88 @@ const createCurrentMigrationDataStore = async (targetMigrationName) => {
|
|
|
1172
1174
|
return store;
|
|
1173
1175
|
};
|
|
1174
1176
|
//#endregion
|
|
1177
|
+
//#region src/migration/exec/getMigrationTarget.ts
|
|
1178
|
+
const getMigrationTargets = (files, current) => {
|
|
1179
|
+
const currentIndex = current ? files.indexOf(current) + 1 : 0;
|
|
1180
|
+
const targetIndex = files.indexOf(require_util.config().migration.target || files[files.length - 1]) + 1;
|
|
1181
|
+
if (currentIndex === -1 || targetIndex === -1) throw new Error("migration target not found");
|
|
1182
|
+
if (targetIndex >= currentIndex) return {
|
|
1183
|
+
direction: "up",
|
|
1184
|
+
files: files.slice(currentIndex, targetIndex)
|
|
1185
|
+
};
|
|
1186
|
+
return {
|
|
1187
|
+
direction: "down",
|
|
1188
|
+
files: files.slice(targetIndex, currentIndex).reverse()
|
|
1189
|
+
};
|
|
1190
|
+
};
|
|
1191
|
+
//#endregion
|
|
1192
|
+
//#region src/migration/exec/runMigration.ts
|
|
1193
|
+
const runMigration = async (client, store, migrationName, direction, options) => {
|
|
1194
|
+
const sqls = store.getSql();
|
|
1195
|
+
const conf = store.getUpdateConfig();
|
|
1196
|
+
if (conf) require_util.setConfig(conf);
|
|
1197
|
+
store.resetQueue();
|
|
1198
|
+
if (!options.silent) sqls.forEach(Console.log);
|
|
1199
|
+
if (options.dry) return;
|
|
1200
|
+
const transaction = await client.transaction();
|
|
1201
|
+
try {
|
|
1202
|
+
for (const sql of sqls) await transaction.rawQuery(sql).catch((e) => {
|
|
1203
|
+
Console.error(`ERROR ON ${migrationName}`);
|
|
1204
|
+
Console.error(`SQL: ${sql}`);
|
|
1205
|
+
Console.error(`MESSAGE: ${e.message}`);
|
|
1206
|
+
process.exit(1);
|
|
1207
|
+
});
|
|
1208
|
+
await transaction.query`insert into ${() => require_util.config().migration.table} (name, direction) values (${[migrationName, direction]})`;
|
|
1209
|
+
return await transaction.commit();
|
|
1210
|
+
} catch (e) {
|
|
1211
|
+
await transaction.rollback();
|
|
1212
|
+
throw e;
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
//#endregion
|
|
1216
|
+
//#region src/migration/controller.ts
|
|
1217
|
+
var MigrationController = class {
|
|
1218
|
+
async migrate(client, currentMigration, options, execute = runMigration) {
|
|
1219
|
+
const fileNames = getMigrationFileNames();
|
|
1220
|
+
if (!options.silent) Console.log("--current migration--: " + currentMigration);
|
|
1221
|
+
let store = await createCurrentMigrationDataStore(currentMigration);
|
|
1222
|
+
if (store.getUpdateConfig()) require_util.setConfig(store.getUpdateConfig());
|
|
1223
|
+
const target = getMigrationTargets(fileNames, currentMigration);
|
|
1224
|
+
for (const tsFileName of target.files) {
|
|
1225
|
+
if (!options.silent) Console.log("---------\n" + tsFileName);
|
|
1226
|
+
store = await readMigration(store, tsFileName, target.direction);
|
|
1227
|
+
await execute(client, store, tsFileName, target.direction, options);
|
|
1228
|
+
store.resetQueue();
|
|
1229
|
+
}
|
|
1230
|
+
return {
|
|
1231
|
+
store: store.serialize(),
|
|
1232
|
+
currentMigration: require_util.config().migration.target || fileNames[fileNames.length - 1]
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
//#endregion
|
|
1237
|
+
//#region src/cli/commands/generateTestMigrationFile.ts
|
|
1238
|
+
async function generateTestMigrationFile(client) {
|
|
1239
|
+
try {
|
|
1240
|
+
await compileMigrationFiles();
|
|
1241
|
+
const migration = new MigrationController();
|
|
1242
|
+
const sqls = [];
|
|
1243
|
+
const exec = async (_, store) => {
|
|
1244
|
+
if (!store.currentOption.skipOnTest) sqls.push(...store.getSql());
|
|
1245
|
+
};
|
|
1246
|
+
await migration.migrate(client, void 0, {
|
|
1247
|
+
generateFiles: false,
|
|
1248
|
+
silent: true,
|
|
1249
|
+
dry: false,
|
|
1250
|
+
skipBuild: false
|
|
1251
|
+
}, exec);
|
|
1252
|
+
node_fs.default.writeFileSync((0, node_path.join)(require_util.config().migration.dir, "test.migration.json"), JSON.stringify(sqls));
|
|
1253
|
+
} catch (e) {
|
|
1254
|
+
Console.error(e.message);
|
|
1255
|
+
throw e;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
//#endregion
|
|
1175
1259
|
//#region src/generatorv2/fs/emptyDir.ts
|
|
1176
1260
|
async function emptyDir(dir) {
|
|
1177
1261
|
let items;
|
|
@@ -3494,74 +3578,15 @@ var CodeGen_v2 = class {
|
|
|
3494
3578
|
}
|
|
3495
3579
|
};
|
|
3496
3580
|
//#endregion
|
|
3497
|
-
//#region src/migration/exec/getMigrationTarget.ts
|
|
3498
|
-
const getMigrationTargets = (files, current) => {
|
|
3499
|
-
const currentIndex = current ? files.indexOf(current) + 1 : 0;
|
|
3500
|
-
const targetIndex = files.indexOf(require_util.config().migration.target || files[files.length - 1]) + 1;
|
|
3501
|
-
if (currentIndex === -1 || targetIndex === -1) throw new Error("migration target not found");
|
|
3502
|
-
if (targetIndex >= currentIndex) return {
|
|
3503
|
-
direction: "up",
|
|
3504
|
-
files: files.slice(currentIndex, targetIndex)
|
|
3505
|
-
};
|
|
3506
|
-
return {
|
|
3507
|
-
direction: "down",
|
|
3508
|
-
files: files.slice(targetIndex, currentIndex).reverse()
|
|
3509
|
-
};
|
|
3510
|
-
};
|
|
3511
|
-
//#endregion
|
|
3512
|
-
//#region src/migration/exec/runMigration.ts
|
|
3513
|
-
const runMigration = async (client, store, migrationName, direction, options) => {
|
|
3514
|
-
const sqls = store.getSql();
|
|
3515
|
-
const conf = store.getUpdateConfig();
|
|
3516
|
-
if (conf) require_util.setConfig(conf);
|
|
3517
|
-
store.resetQueue();
|
|
3518
|
-
if (!options.silent) sqls.forEach(Console.log);
|
|
3519
|
-
if (options.dry) return;
|
|
3520
|
-
const transaction = await client.transaction();
|
|
3521
|
-
try {
|
|
3522
|
-
for (const sql of sqls) await transaction.rawQuery(sql).catch((e) => {
|
|
3523
|
-
Console.error(`ERROR ON ${migrationName}`);
|
|
3524
|
-
Console.error(`SQL: ${sql}`);
|
|
3525
|
-
Console.error(`MESSAGE: ${e.message}`);
|
|
3526
|
-
process.exit(1);
|
|
3527
|
-
});
|
|
3528
|
-
await transaction.query`insert into ${() => require_util.config().migration.table} (name, direction) values (${[migrationName, direction]})`;
|
|
3529
|
-
return await transaction.commit();
|
|
3530
|
-
} catch (e) {
|
|
3531
|
-
await transaction.rollback();
|
|
3532
|
-
throw e;
|
|
3533
|
-
}
|
|
3534
|
-
};
|
|
3535
|
-
//#endregion
|
|
3536
|
-
//#region src/migration/controller.ts
|
|
3537
|
-
var MigrationController = class {
|
|
3538
|
-
async migrate(client, options) {
|
|
3539
|
-
const fileNames = getMigrationFileNames();
|
|
3540
|
-
const currentMigration = await getCurrentMigration(client, options);
|
|
3541
|
-
if (!options.silent) Console.log("--current migration--: " + currentMigration);
|
|
3542
|
-
let store = await createCurrentMigrationDataStore(currentMigration);
|
|
3543
|
-
if (store.getUpdateConfig()) require_util.setConfig(store.getUpdateConfig());
|
|
3544
|
-
const target = getMigrationTargets(fileNames, currentMigration);
|
|
3545
|
-
for (const tsFileName of target.files) {
|
|
3546
|
-
if (!options.silent) Console.log("---------\n" + tsFileName);
|
|
3547
|
-
store = await readMigration(store, tsFileName, target.direction);
|
|
3548
|
-
await runMigration(client, store, tsFileName, target.direction, options);
|
|
3549
|
-
store.resetQueue();
|
|
3550
|
-
}
|
|
3551
|
-
return {
|
|
3552
|
-
store: store.serialize(),
|
|
3553
|
-
currentMigration: require_util.config().migration.target || fileNames[fileNames.length - 1]
|
|
3554
|
-
};
|
|
3555
|
-
}
|
|
3556
|
-
};
|
|
3557
|
-
//#endregion
|
|
3558
3581
|
//#region src/cli/commands/migrate.ts
|
|
3559
3582
|
const migrate = async (client, options) => {
|
|
3560
3583
|
let current;
|
|
3561
3584
|
if (!options.silent) Console.log("--migration started--");
|
|
3562
3585
|
try {
|
|
3563
3586
|
if (!options.skipBuild) await compileMigrationFiles();
|
|
3564
|
-
const
|
|
3587
|
+
const migration = new MigrationController();
|
|
3588
|
+
const currentMigration = await getCurrentMigration(client, options);
|
|
3589
|
+
const result = await migration.migrate(client, currentMigration, options);
|
|
3565
3590
|
current = result.currentMigration;
|
|
3566
3591
|
if (options.generateFiles) {
|
|
3567
3592
|
const storeHandler = new DataStoreHandler(result.store);
|
|
@@ -3647,6 +3672,12 @@ Object.defineProperty(exports, "defaultGQLOption", {
|
|
|
3647
3672
|
return defaultGQLOption;
|
|
3648
3673
|
}
|
|
3649
3674
|
});
|
|
3675
|
+
Object.defineProperty(exports, "generateTestMigrationFile", {
|
|
3676
|
+
enumerable: true,
|
|
3677
|
+
get: function() {
|
|
3678
|
+
return generateTestMigrationFile;
|
|
3679
|
+
}
|
|
3680
|
+
});
|
|
3650
3681
|
Object.defineProperty(exports, "getMigrationFileNames", {
|
|
3651
3682
|
enumerable: true,
|
|
3652
3683
|
get: function() {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { s as SqlValueType } from "../dbClient-Bnk1JKBU.cjs";
|
|
1
|
+
import { l as SqlValueType, n as ComparisonOperators, p as NestedPartial, u as SasatConfig } from "../comparison-Bkk-qNRi.cjs";
|
|
3
2
|
|
|
4
3
|
//#region src/migration/data/relation.d.ts
|
|
5
4
|
type Relation = "One" | "OneOrZero" | "Many";
|
|
@@ -586,6 +585,7 @@ interface SasatMigration {
|
|
|
586
585
|
afterUp?: () => void | Promise<void>;
|
|
587
586
|
beforeDown?: () => void | Promise<void>;
|
|
588
587
|
afterDown?: () => void | Promise<void>;
|
|
588
|
+
skipOnTest?: boolean | undefined;
|
|
589
589
|
}
|
|
590
590
|
//#endregion
|
|
591
591
|
//#region src/migration/makeCondition.d.ts
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { s as SqlValueType } from "../dbClient-TBYnlvTc.mjs";
|
|
1
|
+
import { l as SqlValueType, n as ComparisonOperators, p as NestedPartial, u as SasatConfig } from "../comparison-HpKmxsjs.mjs";
|
|
3
2
|
|
|
4
3
|
//#region src/migration/data/relation.d.ts
|
|
5
4
|
type Relation = "One" | "OneOrZero" | "Many";
|
|
@@ -586,6 +585,7 @@ interface SasatMigration {
|
|
|
586
585
|
afterUp?: () => void | Promise<void>;
|
|
587
586
|
beforeDown?: () => void | Promise<void>;
|
|
588
587
|
afterDown?: () => void | Promise<void>;
|
|
588
|
+
skipOnTest?: boolean | undefined;
|
|
589
589
|
}
|
|
590
590
|
//#endregion
|
|
591
591
|
//#region src/migration/makeCondition.d.ts
|