-
-
Notifications
You must be signed in to change notification settings - Fork 591
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
Migration tool #117
Migration tool #117
Conversation
Looks good so far based on the description. One high-level comment: The most common thing we're likely to want is to apply all unapplied migrations, and we will want to apply them in order. I think what most ORMs do is to name files with a time/datestamp at the front, and treat that as the explicit order and id, rather than embedded the id in the migration file itself. Also we'll want a command that applies all unapplied migrations. |
return | ||
} | ||
} | ||
for _, sqlStmt := range migration.DownSQL { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this for loop doesn't need to be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, didn't see that the output of this loop is used in the next statement. But see comment below.
Done reviewing. Generally very excited about this, thanks for implementing so fast! |
…n dir, added various util functions for future work on apply-unapplied subcommand and such
Is this ready for re-review? Also, I'm very confused about why Travis is failing. Have you merged the latest master? |
It should be now! I've added a migration directory flag/envvar ( |
Also very confused about why Travis is failing... (merged latest master before pushing my most recent commits) |
I've retriggered the Travis build and will try it locally after seeing what happens @ Travis. |
Seems a |
Been a while since there was any activity here, are we still planning to take this? |
@bdaehlie I don't want to diminish roland any, but I would rather just use db-migrate or one of the other well-supported migration tools than to roll our own. |
If we're going to use an existing db migration tool, then can we close issue #111, right? Are we confident that another tool will work for us? |
I'd be happy to scrap this, I think db-migrate, or, if we wanted to stick
|
I recommend we close this pull request, change issue #111 to "question" rather than "enhancement", then close it out after selecting an existing tool to use. |
That sounds great. Thanks guys. |
This adds a basic migration tool (#111)
boulder-migrator
(inboulder/cmd/boulder-migrator/main.go
) that can be used to apply migrations, revert the last migration, revert to a specific migration, and list currently applied migrations.The tool uses a SQL table,
migrations
to store information about migrations that have already been applied that looks like thisBy packaging migrations into a JSON file containing both the migration SQL and the reversion SQL we can easily rollback the last migration, or to an arbitary migration ID, by storing the reversion SQL in the
migrations
table. A basic migration file might look something like thisThis file can be applied using the subcommand
apply
The applied migrations can be listed using
list-applied
and the last migration can be reverted using
revert-last
etc etc etc.
The help dialog should pretty much explain what is going on...
Side note
One note, which may actually apply to other parts of the
SA
code base, to getDATETIME
columns toScan
to atime.Time
object when using MySQL the DSNparseTime=true
needs to be present in the connection URI orScan
will throw the errorScan error on column index 2: unsupported driver -> Scan pair: []uint8 -> *time.Time
.