mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-21 16:03:26 +00:00
The row-level Run action warns when earlier migrations are still pending, but the create-and-run paths ran a just-created migration with `only` directly, applying it ahead of older pending migrations without that confirmation. Reuse the same "Run migration out of order" confirmation across all create-and-run paths via a shared helper (datatableMigrationUtils): - NewDataTableMigrationModal "Create and run" (and the DDL guard path) - DatatableSchemaDiff fork→parent merge - dbOps schema ops (DB manager create/alter/drop) — the pure factory throws a MigrationRunCancelled sentinel on decline, which DBTableEditor treats as a silent cancel Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { WorkspaceService, type DatatableMigrationWithStatus } from '$lib/gen'
|
|
|
|
/**
|
|
* Migrations that are defined but not yet applied. A newly-created migration
|
|
* always gets the highest timestamp, so every pending migration is "earlier":
|
|
* running the new one on its own would apply it ahead of them (out of order).
|
|
*/
|
|
export function pendingMigrations(
|
|
migrations: DatatableMigrationWithStatus[]
|
|
): DatatableMigrationWithStatus[] {
|
|
return migrations.filter((m) => m.status !== 'ran')
|
|
}
|
|
|
|
/** Fetch the data table's migration status and return the pending ones. */
|
|
export async function fetchPendingMigrations(
|
|
workspace: string,
|
|
datatableName: string
|
|
): Promise<DatatableMigrationWithStatus[]> {
|
|
const { migrations } = await WorkspaceService.getDatatableMigrationsStatus({
|
|
workspace,
|
|
datatableName
|
|
})
|
|
return pendingMigrations(migrations)
|
|
}
|
|
|
|
/** Confirmation copy shown before running a just-created migration ahead of
|
|
* `count` still-pending earlier ones (mirrors the row-level Run warning). */
|
|
export function outOfOrderRunMessage(count: number): string {
|
|
return `${count} earlier migration(s) have not been run yet. This migration might depend on them. Run it anyway?`
|
|
}
|