dox_migration 3.2.0
dox_migration: ^3.2.0 copied to clipboard
Database migration package for Postgres, MySQL, MariaDB and SQLite
3.2.0 #
- Fix: on SQLite, the foreign key check after a migration now fails only for rows that this migration broke. Before, an old broken row made every later migration and
reset()fail. - Ships an AI agent skill (dox-migration-guide). Install it in your app with
dart run skills@ get. - New:
Migrator(flags: ...)gives theOrmFlagsof the app to theSchemaof each Dart migration, eg.flags: databaseConfig.flags. With noflags, it usesSqlQueryBuilder().flags.OrmFlags.laravelPostgresTypeschanges the column types of new Postgres tables.OrmFlagsis now exported bydox_migration. - New:
Migrator().rollback(batch: 3)rolls back only the migrations of batch 3, newest first.bin/migrate.dart rollback --batch=3(or--batch 3) does the same. Give--stepor--batch, not both. As before, the first word afterrollbackmust be--stepor--batch, and other words after it are not used. They now print a warning. - New: when the Migrator runs on a connection of the ORM (eg.
connection: SqlQueryBuilder().dbDriver), its queries now go to the query listeners and the slow query log of dox_orm.
3.1.0 #
- Fix: rollback no longer stops when the file of a migration that already ran is gone. Like Laravel, it prints "Migration not found:
- New public library
package:dox_migration/env.dart. It exportsloadEnv, the.envreader of the Migrator. The dox CLI uses it to readAPP_ENV.
3.0.1 #
- Version bump only, to match dox_orm.
3.0.0 #
- The first stable release.
3.0.0-rc.1 #
- Change: without
DATABASE_URLandDB_CONNECTION, the migrations now use SQLite with the filedb/dox.sqlite. This is the same default as the app template. Before, they used Postgres with the databasedox, so with an empty.envthe app and the migrations used different databases. Postgres and MySQL still usedoxwhen no database name is set. An unknownDB_CONNECTIONnow throws an error. - Fix: two app instances that start at the same time no longer run the same migrations twice. A run now holds a lock. Postgres uses an advisory lock. MySQL and MariaDB use
GET_LOCK. SQLite uses the file<database>.locknext to the database file. The other runs wait, then see that the migrations are done. The lock is released when the run ends or fails.
3.0.0-alpha.14 #
- Version bump only, to match the other packages.
3.0.0-alpha.13 #
- Version bump only, to match the other packages.
3.0.0-alpha.12 #
- Version bump only, to match the other packages.
3.0.0-alpha.11 #
- Version bump only, to match the other packages.
3.0.0-alpha.10 #
- Version bump only, to match the other packages.
3.0.0-alpha.9 #
- New
SeederandSeederRunner. A seeder puts data in the database.call()runs other seeders.SeederRunner(seeders: seeders).run(args)runsDatabaseSeeder, or another one with--class=<name>, in one transaction. It reads the database from.env, the same as the migrations. - New
Migrator.fresh()and thefreshcommand ofMigrator.run(). It drops every table of the database, then runs all migrations.
3.0.0-alpha.8 #
- A migration that runs inside a transaction you already opened (eg. with
Migrator(connection: ...)) now uses a savepoint. A failed migration undoes only its own work.
3.0.0-alpha.7 #
- Breaking: migrations run on the dox_orm drivers: the native Postgres and MySQL drivers, and SQLite. The
postgresandmysql_dartpackages are gone. When the native library does not load, the migration stops with an error that says why. - Breaking:
Migrator(connection: ...)takes a dox_ormDBDrivernow, eg.SqlQueryBuilder().dbDriver. The migrator does not close it. NewMigrator(config: ...)takes aConnectionConfig, eg.databaseConfig.getConnectionConfig(), and closes it at the end. - TLS works the same as dox_orm. For Postgres,
sslmode=requireencrypts andverify-fullalso checks the certificate. For MySQL the certificate is checked. AddverifyCertificate=falsetoDATABASE_URLto skip the MySQL check in development.
3.0.0-alpha.6 #
- A
DB_HOSTthat starts with/is a MySQL Unix socket file too (Postgres: the socket folder).?socket=/pathworks in amysql://DATABASE_URL.
3.0.0-alpha.5 #
DATABASE_URLsupport. When it is set, it wins overDB_CONNECTIONand the otherDB_*keys. Itssslmode(Postgres) orssl(MySQL) option turns TLS on.- A
DB_HOSTthat starts with/is a Postgres Unix socket folder, like/cloudsql/project:region:instanceon Cloud Run. - Migrations read real environment variables too. Before, a
.envfile hid them. Now a real env var wins over.env, the same asEnv.get()of dox_core. An empty value, ornull, counts as missing.
3.0.0-alpha.4 #
- Version bump only, to match the other packages.
3.0.0-alpha.3 #
- Version bump only, to match the other packages.
3.0.0-alpha.2 #
- Needs Dart 3.13 or newer.
- All dependencies updated to their latest versions.
sqlite33 (SQLite is bundled, no system library needed).
3.0.0-alpha.1 #
- Removed the
dox_migrationexecutable from pubspec (its script was removed before). Use thedoxCLI. - Added SQLite:
DB_CONNECTION=sqliteandDB_DATABASE=<file path>. - MySQL driver is now
mysql_dart(wasmysql1). The MySQL 8 default login (caching_sha2_password) works. migrate()and the other commands also take a pool (postgresPool, mysqlMySQLConnectionPool). Each file runs in one transaction on one connection.- Breaking: a passed mysql connection must be a
mysql_dartMySQLConnectionorMySQLConnectionPool(notmysql1). - Needs Dart 3.6 or newer.
3.0.0 #
- Support MySQL. Set
DB_CONNECTION=mysqlin.env(default ispostgres) - Run each statement of a
.sqlmigration one by one, inside a transaction - Rollback undoes only the last batch, newest first. Add
step,reset()andrefresh() - Stop at the first failed migration
- Fix
.sqlparsing: a-in the sql no longer cuts theupordownpart - Fix statement split:
;inside quotes, comments or$$bodies does not split
2.0.0 #
- Release stable version v2.0
2.0.0-alpha.2 #
- Remove .dart option
1.0.4 #
- Improve loading .env
1.0.3 #
- Bug fixed on sql rollback
1.0.2 #
- Fixed rollback issues
1.0.1 #
- Close connection when running from cli
1.0.0 #
- Initial version.