@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.js
CHANGED
|
@@ -3774,22 +3774,46 @@ async function ensureTaskTables(context, options = {}) {
|
|
|
3774
3774
|
}
|
|
3775
3775
|
}
|
|
3776
3776
|
const { actions } = await ensureSchema(db, spec, { dryRun, logger: context.logger });
|
|
3777
|
+
const legacyDrops = await dropLegacyTaskNameColumn(db, [tasksTable, historyTable], {
|
|
3778
|
+
dryRun,
|
|
3779
|
+
log,
|
|
3780
|
+
label
|
|
3781
|
+
});
|
|
3782
|
+
const allActions = [...actions, ...legacyDrops];
|
|
3777
3783
|
if (dryRun) {
|
|
3778
|
-
if (
|
|
3784
|
+
if (allActions.length === 0) {
|
|
3779
3785
|
log.info?.(`[tasks-schema] dryRun \u2014 ${label}: queue "${queueName}" already up to date; no DDL`);
|
|
3780
3786
|
} else {
|
|
3781
3787
|
log.info?.(
|
|
3782
|
-
`[tasks-schema] dryRun \u2014 ${label}: would run ${
|
|
3788
|
+
`[tasks-schema] dryRun \u2014 ${label}: would run ${allActions.length} statement(s) for queue "${queueName}":`
|
|
3783
3789
|
);
|
|
3784
|
-
for (const s of
|
|
3790
|
+
for (const s of allActions) log.info?.(` - ${s}`);
|
|
3785
3791
|
}
|
|
3786
|
-
} else if (
|
|
3792
|
+
} else if (allActions.length > 0) {
|
|
3787
3793
|
log.info?.(
|
|
3788
|
-
`[tasks-schema] ${label}: applied ${
|
|
3794
|
+
`[tasks-schema] ${label}: applied ${allActions.length} DDL statement(s) for queue "${queueName}"`
|
|
3789
3795
|
);
|
|
3790
3796
|
}
|
|
3791
3797
|
}
|
|
3792
3798
|
}
|
|
3799
|
+
async function dropLegacyTaskNameColumn(db, tableNames, { dryRun, log, label }) {
|
|
3800
|
+
const actions = [];
|
|
3801
|
+
for (const table of tableNames) {
|
|
3802
|
+
if (!await db.tableExists(table).catch(() => false)) continue;
|
|
3803
|
+
const hasTask = await db.schema.hasColumn(table, "task");
|
|
3804
|
+
const hasName = await db.schema.hasColumn(table, "name");
|
|
3805
|
+
if (!hasTask || !hasName) continue;
|
|
3806
|
+
const sql = `ALTER TABLE "${table}" DROP COLUMN IF EXISTS "task"`;
|
|
3807
|
+
actions.push(sql);
|
|
3808
|
+
if (dryRun) {
|
|
3809
|
+
log?.info?.(`[tasks-schema] dryRun \u2014 ${label}: ${sql}`);
|
|
3810
|
+
} else {
|
|
3811
|
+
await db.raw(sql);
|
|
3812
|
+
log?.info?.(`[tasks-schema] ${label}: dropped legacy column ${table}.task`);
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
return actions;
|
|
3816
|
+
}
|
|
3793
3817
|
async function updateTaskProgress(context, tasksTable, taskId, progress) {
|
|
3794
3818
|
const db = getDb(context);
|
|
3795
3819
|
await db(tasksTable).where({ id: taskId }).update({
|