migrate -path PATH/TO/MIGRATION/FOLDER -database URI version migrate -path PATH/TO/MIGRATION/FOLDER -database URI -verbose up 1 migrate -path PATH/TO/MIGRATION/FOLDER -database URI -verbose down 1 migrate -path PATH/TO/MIGRATION/FOLDER -database URI -verbose force N
常用命令:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Commands: create [-ext E] [-dir D] [-seq] [-digits N] [-format] [-tz] NAME Create a set of timestamped up/down migrations titled NAME, in directory D with extension E. Use -seq option to generate sequential up/down migrations with N digits. Use -format option to specify a Go time format string. Note: migrations with the same time cause "duplicate migration version" error. Use -tz option to specify the timezone that will be used when generating non-sequential migrations (defaults: UTC).
goto V Migrate to version V up [N] Apply all or N up migrations down [N] [-all] Apply all or N down migrations Use -all to apply all down migrations drop [-f] Drop everything inside database Use -f to bypass confirmation force V Set version V but don't run migration (ignores dirty state) version Print current migration version
已知的小遗憾是不太适配 ByteDance 出的 ByteHouse CDW(云数仓版),因为 ByteHouse CDW 的 SHOW TABLES FROM "db" LIKE '...' 语句查询的结果不正确。
Migrations created during the development process are timestamped and sequential versions are ran on production.
We believe this method will prevent the problem of conflicting versions when writing software in a team environment.
常用命令:
1 2 3 4 5 6 7 8 9 10 11 12 13
Commands: up Migrate the DB to the most recent version available up-by-one Migrate the DB up by 1 up-to VERSION Migrate the DB to a specific VERSION down Roll back the version by 1 down-to VERSION Roll back to a specific VERSION redo Re-run the latest migration reset Roll back all migrations status Dump the migration status for the current DB version Print the current version of the database create NAME [sql|go] Creates new migration file with the current timestamp fix Apply sequential ordering to migrations validate Check migration files without running them