-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrations with SQL-files #76
Comments
I'll take it! |
How I understand task description:
Please, explain if it is possible to define custom versioning style (or at least prefix) - numbers, letters or somethings else? |
Alternatively, CLI may detect current versioning scheme (dates, sequential numbers, etc.) and play along. But I'm not sure we want to implement this feature now. |
Just curious if you even want to tackle this given that there are several enterprise-ready, mature schema migration tools already available. DRY. |
The first step is to create Go library (in separate package
gopkg.in/reform.v1/migrator
) and CLI (inreform-db
) to apply SQL migrations.Basics
Migration is a sequence of SQL DDL statements. Migrations are versioned. A version is an opaque string. Versions are sorted by
sort.Strings
.Applied migrations are tracked in database table
schema_migrations
. In PostgreSQL syntax:When applying migrations, all not-applied migrations should be run, independent on a version. For example, given migrations A, B, C, D, E, and B and D are already applied, A, C, and E still should be run.
Example migration file:
2006-01-02-15-04-create-people.sql
-- +migration VERSION
is magic version comment. VERSION should match filename prefix.Go Package API
TBD.
CLI
It should create file
<2006-01-02-15-04>-create-people.sql
with2006-01-02-15-04
is a time format for current UTC time.Random notes
The text was updated successfully, but these errors were encountered: