Skip to main content

dox_migration 3.2.3 copy "dox_migration: ^3.2.3" to clipboard
dox_migration: ^3.2.3 copied to clipboard

Database migration package for Postgres, MySQL, MariaDB and SQLite

3.2.3 #

  • No changes. The version goes up with dox_orm 3.2.3.

3.2.2 #

  • Change: every Logger line starts with a dim [migration] tag, then the text in its color. Logger.warn was blue, now it is yellow like the other packages. The migrate:status table is the same.

3.2.1 #

  • Fix: loadEnv (the .env reader of the Migrator and the dox CLI) read some values wrong. APP_ENV=production # live gave production # live, so the CLI did not see production and did not ask before migrate:fresh. export KEY=value was not read. Every quote in a value was removed, so it's"q became itsq. Now it reads a value like the app does: export is allowed, a # after a space or tab starts a comment, KEY=#fff keeps the #, and only one pair of quotes around the value is removed. Comment lines, \r\n line ends and a BOM are fine. A real environment variable still wins over .env.
  • Fix: a bad DATABASE_URL no longer shows its password in the error (see dox_orm).

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 the OrmFlags of the app to the Schema of each Dart migration, eg. flags: databaseConfig.flags. With no flags, it uses SqlQueryBuilder().flags. OrmFlags.laravelPostgresTypes changes the column types of new Postgres tables. OrmFlags is now exported by dox_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 --step or --batch, not both. As before, the first word after rollback must be --step or --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 exports loadEnv, the .env reader of the Migrator. The dox CLI uses it to read APP_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_URL and DB_CONNECTION, the migrations now use SQLite with the file db/dox.sqlite. This is the same default as the app template. Before, they used Postgres with the database dox, so with an empty .env the app and the migrations used different databases. Postgres and MySQL still use dox when no database name is set. An unknown DB_CONNECTION now 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>.lock next 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 Seeder and SeederRunner. A seeder puts data in the database. call() runs other seeders. SeederRunner(seeders: seeders).run(args) runs DatabaseSeeder, or another one with --class=<name>, in one transaction. It reads the database from .env, the same as the migrations.
  • New Migrator.fresh() and the fresh command of Migrator.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 postgres and mysql_dart packages are gone. When the native library does not load, the migration stops with an error that says why.
  • Breaking: Migrator(connection: ...) takes a dox_orm DBDriver now, eg. SqlQueryBuilder().dbDriver. The migrator does not close it. New Migrator(config: ...) takes a ConnectionConfig, eg. databaseConfig.getConnectionConfig(), and closes it at the end.
  • TLS works the same as dox_orm. For Postgres, sslmode=require encrypts and verify-full also checks the certificate. For MySQL the certificate is checked. Add verifyCertificate=false to DATABASE_URL to skip the MySQL check in development.

3.0.0-alpha.6 #

  • A DB_HOST that starts with / is a MySQL Unix socket file too (Postgres: the socket folder). ?socket=/path works in a mysql:// DATABASE_URL.

3.0.0-alpha.5 #

  • DATABASE_URL support. When it is set, it wins over DB_CONNECTION and the other DB_* keys. Its sslmode (Postgres) or ssl (MySQL) option turns TLS on.
  • A DB_HOST that starts with / is a Postgres Unix socket folder, like /cloudsql/project:region:instance on Cloud Run.
  • Migrations read real environment variables too. Before, a .env file hid them. Now a real env var wins over .env, the same as Env.get() of dox_core. An empty value, or null, 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.
  • sqlite3 3 (SQLite is bundled, no system library needed).

3.0.0-alpha.1 #

  • Removed the dox_migration executable from pubspec (its script was removed before). Use the dox CLI.
  • Added SQLite: DB_CONNECTION=sqlite and DB_DATABASE=<file path>.
  • MySQL driver is now mysql_dart (was mysql1). The MySQL 8 default login (caching_sha2_password) works.
  • migrate() and the other commands also take a pool (postgres Pool, mysql MySQLConnectionPool). Each file runs in one transaction on one connection.
  • Breaking: a passed mysql connection must be a mysql_dart MySQLConnection or MySQLConnectionPool (not mysql1).
  • Needs Dart 3.6 or newer.

3.0.0 #

  • Support MySQL. Set DB_CONNECTION=mysql in .env (default is postgres)
  • Run each statement of a .sql migration one by one, inside a transaction
  • Rollback undoes only the last batch, newest first. Add step, reset() and refresh()
  • Stop at the first failed migration
  • Fix .sql parsing: a - in the sql no longer cuts the up or down part
  • 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.
1
likes
160
points
3.12k
downloads

Documentation

API reference

Publisher

verified publisherdartondox.dev

Weekly Downloads

Database migration package for Postgres, MySQL, MariaDB and SQLite

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

dox_orm, sqlite3

More

Packages that depend on dox_migration