feat(migrations): complete idempotent migrator CLI and Docker packaging - #1
Open
WoLfulus wants to merge 1 commit into
Open
feat(migrations): complete idempotent migrator CLI and Docker packaging#1WoLfulus wants to merge 1 commit into
WoLfulus wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
compileModule->modules.compilewhen persisting thecompiled up/down script on each migration row.
factoryby rawurl.protocolinstead ofthe mapped dialect name (sqlite/postgres/mysql were never resolved).
executedtimestamps as ISO strings; aDateobject cannot bebound by the sqlite driver.
create()accepts a string URL;build()/create()/dialect()/destroy()get explicit return types; unused/type-only kysely imports cleaned up.
getFutureMigrationsfilter.CLI (cli/*):
migrate: apply, status, list, rollback, build.down (using the compiled down script stored in the database) when the image
is behind;
--no-rollbackrefuses instead. status/list/rollback added.--database/--migrations-diroptions with DATABASE / MIGRATIONS_DIRenv fallbacks resolved in support.ts.
applyon start)and invokes
docker build;--dockerfilerenders only../cliexport.Add README documenting the workflow.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01PsF13E7YqG6oAshFoTdaUM