Files
windmill/frontend/src/lib/components/workspaceSettings/datatableMigrationUtils.ts
T
2410790c7e feat: scope data table migrations to the schemas they declare (#11756)
* feat: scope data table migrations to the schemas they declare

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep unschemed objects and unqualified sql out of per-schema scopes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: order snapshot prerequisites and widen scopes to what they reference

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: point ee-repo-ref at the migration_scope allowlist entry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: infer scopes only from generated ddl and snapshot every user object

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: snapshot every schema from one exported snapshot, infer only unedited sql

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: keep the initial snapshot whole-database and scopes author-declared

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: warn before an out-of-order run when applied status is unknown

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: update ee-repo-ref to 57f4b973e2369f54a89817ff23dc44047ba7b9e4

This commit updates the EE repository reference after PR #880 was merged in windmill-ee-private.

Previous ee-repo-ref: abb876d6234d5dfe7c644fdf12cf55f7bc1db1cc

New ee-repo-ref: 57f4b973e2369f54a89817ff23dc44047ba7b9e4

Automated by sync-ee-ref workflow.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
2026-10-14 11:34:21 +00:00

35 lines
1.4 KiB
TypeScript

import { WorkspaceService, type DatatableMigrationWithStatus } from '$lib/gen'
import { migrationScope, scopesOverlap } from '../datatableMigrationSchemas'
/**
* The pending migrations a new migration declaring `sql`'s scope would run ahead of. A
* newly-created migration always gets the highest timestamp, so every pending migration is
* "earlier"; only those whose scope overlaps its own can be ones it depends on.
*/
export function pendingMigrations(
migrations: DatatableMigrationWithStatus[],
sql: string
): DatatableMigrationWithStatus[] {
const scope = migrationScope(sql)
return migrations.filter((m) => m.status !== 'ran' && scopesOverlap(m.schemas, scope))
}
/** Fetch the data table's migration status and return the pending ones `sql` would run ahead of. */
export async function fetchPendingMigrations(
workspace: string,
datatableName: string,
sql: string
): Promise<DatatableMigrationWithStatus[]> {
const { migrations } = await WorkspaceService.getDatatableMigrationsStatus({
workspace,
datatableName
})
return pendingMigrations(migrations, sql)
}
/** 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) touching the same schemas have not been run yet. This migration might depend on them. Run it anyway?`
}