14 Commits

Author SHA1 Message Date
4a9c331ef9
Fix INSERT INTO _migrations ordering in create and fixup
The create subcommand generated .up.sql files with INSERT INTO
_migrations as the FIRST statement, before the actual DDL. If the
DDL fails, the migration is incorrectly marked as applied. Move the
INSERT to be the LAST statement, matching how .down.sql already puts
DELETE FROM _migrations last.

Also fix the automatic fixup logic to append (not prepend) missing
INSERT statements to existing .up.sql files.

Fixes #86
2026-03-30 15:58:21 -06:00
1f61095873
feat(sql-migrate): add sync subcommand
Adds `sql-migrate sync` which outputs a shell script that refreshes
the local migrations.log from the DB by running _migrations.sql.
Uses `|| true` so a fresh DB with no _migrations table yields an
empty log (all migrations pending) rather than an error.

Usage:
  sql-migrate -d ./db/migrations sync | sh
  sql-migrate -d ./db/migrations up | sh
2026-03-23 11:42:23 -06:00
b50696f64d feat(sql-migrate): skip +-prefixed files in migrations directory (refs #68) 2026-03-23 11:39:49 -06:00
3487702bf7 fix(sql-migrate): use 6-digit zero-padded number in init migration filename (refs #68) 2026-03-23 11:39:49 -06:00
4895012d67 fix(sql-migrate): use portable SQL in _migrations table (closes #37) 2026-03-23 11:39:49 -06:00
21ea2d0613
chore(cmd/sql-migrate): bump v2.0.3 2026-01-31 21:22:42 -07:00
b6ffacd0a6
fix(cmd/sql-migrate): spell 'postgres' correctly 2026-01-31 21:21:53 -07:00
e7282c58f3
chore(cmd/sql-migrate): add explicit default for sqlCommand switch 2026-01-31 21:21:53 -07:00
dd4148b88e
chore(cmd/sql-migrate): make file path ormatting consistent for all 'found ./path/to/x' outtput 2026-01-31 21:21:53 -07:00
1ec145b3eb
ref(cmd/sql-migrate/v2): make INSERTs sortable, output cleanup 2026-01-31 01:18:58 -07:00
65f866970e
feat(cmd/sql-migrate/v2): store migrations in db, nix batches 2026-01-31 00:10:06 -07:00
fe6300dacc
chore(cmd/sql-migrate): bump to version 1.0.2 2026-01-13 00:30:48 -07:00
eee1a95f52
ref(cmd/sql-migrate): add package, docs, minor flag parse change 2026-01-13 00:30:08 -07:00
f034cf0529
feat(cmd/sql-migrate): can write up and down migrations 2026-01-13 00:29:55 -07:00