@nmakarov/cli-toolkit 0.43.0 → 0.44.0
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-runner.cjs +29 -5
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +29 -5
- package/dist/cli-runner.js.map +1 -1
- package/dist/filedatabase.cjs +26 -20
- package/dist/filedatabase.cjs.map +1 -1
- package/dist/filedatabase.js +26 -20
- package/dist/filedatabase.js.map +1 -1
- package/dist/index.cjs +69 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +69 -27
- package/dist/index.js.map +1 -1
- package/dist/tasks.cjs +43 -7
- package/dist/tasks.cjs.map +1 -1
- package/dist/tasks.js +43 -7
- package/dist/tasks.js.map +1 -1
- package/package.json +1 -1
package/dist/cli-runner.cjs
CHANGED
|
@@ -3790,22 +3790,46 @@ async function ensureTaskTables(context, options = {}) {
|
|
|
3790
3790
|
}
|
|
3791
3791
|
}
|
|
3792
3792
|
const { actions } = await ensureSchema(db, spec, { dryRun, logger: context.logger });
|
|
3793
|
+
const legacyDrops = await dropLegacyTaskNameColumn(db, [tasksTable, historyTable], {
|
|
3794
|
+
dryRun,
|
|
3795
|
+
log,
|
|
3796
|
+
label
|
|
3797
|
+
});
|
|
3798
|
+
const allActions = [...actions, ...legacyDrops];
|
|
3793
3799
|
if (dryRun) {
|
|
3794
|
-
if (
|
|
3800
|
+
if (allActions.length === 0) {
|
|
3795
3801
|
log.info?.(`[tasks-schema] dryRun \u2014 ${label}: queue "${queueName}" already up to date; no DDL`);
|
|
3796
3802
|
} else {
|
|
3797
3803
|
log.info?.(
|
|
3798
|
-
`[tasks-schema] dryRun \u2014 ${label}: would run ${
|
|
3804
|
+
`[tasks-schema] dryRun \u2014 ${label}: would run ${allActions.length} statement(s) for queue "${queueName}":`
|
|
3799
3805
|
);
|
|
3800
|
-
for (const s of
|
|
3806
|
+
for (const s of allActions) log.info?.(` - ${s}`);
|
|
3801
3807
|
}
|
|
3802
|
-
} else if (
|
|
3808
|
+
} else if (allActions.length > 0) {
|
|
3803
3809
|
log.info?.(
|
|
3804
|
-
`[tasks-schema] ${label}: applied ${
|
|
3810
|
+
`[tasks-schema] ${label}: applied ${allActions.length} DDL statement(s) for queue "${queueName}"`
|
|
3805
3811
|
);
|
|
3806
3812
|
}
|
|
3807
3813
|
}
|
|
3808
3814
|
}
|
|
3815
|
+
async function dropLegacyTaskNameColumn(db, tableNames, { dryRun, log, label }) {
|
|
3816
|
+
const actions = [];
|
|
3817
|
+
for (const table of tableNames) {
|
|
3818
|
+
if (!await db.tableExists(table).catch(() => false)) continue;
|
|
3819
|
+
const hasTask = await db.schema.hasColumn(table, "task");
|
|
3820
|
+
const hasName = await db.schema.hasColumn(table, "name");
|
|
3821
|
+
if (!hasTask || !hasName) continue;
|
|
3822
|
+
const sql = `ALTER TABLE "${table}" DROP COLUMN IF EXISTS "task"`;
|
|
3823
|
+
actions.push(sql);
|
|
3824
|
+
if (dryRun) {
|
|
3825
|
+
log?.info?.(`[tasks-schema] dryRun \u2014 ${label}: ${sql}`);
|
|
3826
|
+
} else {
|
|
3827
|
+
await db.raw(sql);
|
|
3828
|
+
log?.info?.(`[tasks-schema] ${label}: dropped legacy column ${table}.task`);
|
|
3829
|
+
}
|
|
3830
|
+
}
|
|
3831
|
+
return actions;
|
|
3832
|
+
}
|
|
3809
3833
|
async function updateTaskProgress(context, tasksTable, taskId, progress) {
|
|
3810
3834
|
const db = getDb(context);
|
|
3811
3835
|
await db(tasksTable).where({ id: taskId }).update({
|