Skip to content

feat(migrations): complete idempotent migrator CLI and Docker packaging - #1

Open
WoLfulus wants to merge 1 commit into
mainfrom
claude/migrations-cli-implementation-d0n3h1
Open

feat(migrations): complete idempotent migrator CLI and Docker packaging#1
WoLfulus wants to merge 1 commit into
mainfrom
claude/migrations-cli-implementation-d0n3h1

Conversation

@WoLfulus

Copy link
Copy Markdown
Member

Finish the migrations module so it is a working CLI that converges a
database to the Kysely migrations baked into a Docker image, and can build
that image.

Engine (databases.ts):

  • Fix undefined compileModule -> modules.compile when persisting the
    compiled up/down script on each migration row.
  • Fix dialect resolution indexing factory by raw url.protocol instead of
    the mapped dialect name (sqlite/postgres/mysql were never resolved).
  • Bind SQLite executed timestamps as ISO strings; a Date object cannot be
    bound by the sqlite driver.
  • create() accepts a string URL; build()/create()/dialect()/destroy()
    get explicit return types; unused/type-only kysely imports cleaned up.
  • Fix inverted getFutureMigrations filter.

CLI (cli/*):

  • Register subcommands on migrate: apply, status, list, rollback, build.
  • apply idempotently converges: migrates up when the image is ahead, and rolls
    down (using the compiled down script stored in the database) when the image
    is behind; --no-rollback refuses instead. status/list/rollback added.
  • Shared --database / --migrations-dir options with DATABASE / MIGRATIONS_DIR
    env fallbacks resolved in support.ts.
  • build renders a two-stage Dockerfile (compile migrator, run apply on start)
    and invokes docker build; --dockerfile renders only.
  • Remove dead migrator.ts; mod.ts re-exports the library API; add ./cli export.

Add README documenting the workflow.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01PsF13E7YqG6oAshFoTdaUM

Finish the migrations module so it is a working CLI that converges a
database to the Kysely migrations baked into a Docker image, and can build
that image.

Engine (databases.ts):
- Fix undefined `compileModule` -> `modules.compile` when persisting the
  compiled up/down script on each migration row.
- Fix dialect resolution indexing `factory` by raw `url.protocol` instead of
  the mapped dialect name (sqlite/postgres/mysql were never resolved).
- Bind SQLite `executed` timestamps as ISO strings; a `Date` object cannot be
  bound by the sqlite driver.
- `create()` accepts a string URL; `build()`/`create()`/`dialect()`/`destroy()`
  get explicit return types; unused/type-only kysely imports cleaned up.
- Fix inverted `getFutureMigrations` filter.

CLI (cli/*):
- Register subcommands on `migrate`: apply, status, list, rollback, build.
- apply idempotently converges: migrates up when the image is ahead, and rolls
  down (using the compiled down script stored in the database) when the image
  is behind; `--no-rollback` refuses instead. status/list/rollback added.
- Shared `--database` / `--migrations-dir` options with DATABASE / MIGRATIONS_DIR
  env fallbacks resolved in support.ts.
- build renders a two-stage Dockerfile (compile migrator, run `apply` on start)
  and invokes `docker build`; `--dockerfile` renders only.
- Remove dead migrator.ts; mod.ts re-exports the library API; add `./cli` export.

Add README documenting the workflow.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PsF13E7YqG6oAshFoTdaUM
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.

2 participants