Skip to content

[codex] Avoid overwriting same-second migrations#112

Merged
KeKs0r merged 3 commits intomainfrom
marc/stabilize-rmv-lifecycle-test
Apr 22, 2026
Merged

[codex] Avoid overwriting same-second migrations#112
KeKs0r merged 3 commits intomainfrom
marc/stabilize-rmv-lifecycle-test

Conversation

@KeKs0r
Copy link
Copy Markdown
Contributor

@KeKs0r KeKs0r commented Apr 22, 2026

Summary

Fixes a flake in the refreshable materialized view lifecycle test by preventing generated migration files from being overwritten when multiple chkit generate runs happen within the same second.

Root Cause

Automatic migration filenames used second-level timestamps plus the default auto name. The lifecycle test generates several different migrations quickly, so a later generate could reuse the same filename and overwrite an already-applied migration. The next migrate then failed correctly with a checksum mismatch.

Changes

  • Write migration files using exclusive create semantics.
  • On filename collision, fall back to deterministic suffixes like _001, _002, etc.
  • Add a regression test that forces two migrations to share the same timestamp and verifies the first file is preserved.

Validation

  • bun test packages/codegen/src/index.test.ts
  • bun run --cwd packages/codegen typecheck
  • bun run --cwd packages/codegen lint
  • bun run --cwd packages/cli typecheck
  • doppler run --project chkit --config ci -- bun test packages/cli/src/clickhouse-live.e2e.test.ts -t "refreshable materialized view lifecycle" --timeout 240000
  • Looped the live lifecycle test 12 times after the fix; all 12 passed.

@KeKs0r KeKs0r force-pushed the marc/stabilize-rmv-lifecycle-test branch from e867d56 to c181d7c Compare April 22, 2026 09:39
@KeKs0r KeKs0r marked this pull request as ready for review April 22, 2026 11:16
@KeKs0r KeKs0r force-pushed the marc/stabilize-rmv-lifecycle-test branch from 960d1c3 to 4717229 Compare April 22, 2026 11:24
@KeKs0r KeKs0r merged commit 03d6f57 into main Apr 22, 2026
2 checks passed
@KeKs0r KeKs0r deleted the marc/stabilize-rmv-lifecycle-test branch April 22, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant