Skip to content

miiigrate 0.1.0

Choose a tag to compare

@heryr heryr released this 19 Jul 16:44

Initial release of miiigrate — forward-only SQL migrations for iii, driven entirely through the database worker (no direct database connection), plus TypeScript codegen of your schema.

Highlights

  • migrate::up — each migration runs as one atomic database::transaction batch: pg_advisory_xact_lock serialization on Postgres, BEGIN IMMEDIATE on SQLite. Concurrent migrators (e.g. multiple replicas with auto: true) are detected and counted as skips, not failures. Checksum drift on an applied file blocks the run (CHECKSUM_MISMATCH) before anything is applied.
  • migrate::status — read-only report: applied / pending / mismatched / missing.
  • migrate::create — UTC-timestamped scaffold with a forward-only header.
  • migrate::codegen — Postgres (full: enums, arrays) and SQLite (basic) → TypeScript. Types describe values as they actually cross database::query (JSON): timestamps are RFC 3339 strings, binary is base64.
  • SQL splitter aware of 'strings', E'…' escapes, "identifiers", $tag$…$tag$ dollar quoting, and nested comments.
  • Checksums SHA-256 with CRLF→LF normalization — a Windows line-ending rewrite is not drift.
  • Playgrounds: SQLite end-to-end scenario and a Postgres 16 two-instance concurrency proof (docker compose).

Requires

The database worker (iii worker add database). Postgres and SQLite in v1; MySQL is rejected with UNSUPPORTED_DIALECT.

Install

iii worker add miiigrate

Binaries below cover linux x64/arm64 and macOS arm64/x64 (tar.gz + sha256).