Skip to content
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

Question. #42

Closed
kaaquist opened this issue May 30, 2018 · 3 comments
Closed

Question. #42

kaaquist opened this issue May 30, 2018 · 3 comments

Comments

@kaaquist
Copy link

Hi, First off thanks for a nice tool.
I have created three func in go that can migrate up, down or tell me version. But I can't really seem go get my head around how to actually start, like init the whole thing. Right now I have a running instance of cockroach and I have created init_up and init_down for all schemas, data etc.
Is there a guide or document that describe the initial steps before first migration?
I hope that you get my question, else please tell me to elaborate. Thanks.

@dhui
Copy link
Member

dhui commented May 30, 2018

You'll need to determine how and when you want to run migrations since that affects how you use the tool.

Personally, my workflow looks like this:

  1. Create migrations using the CLI create command. This ensures that the name of the migration is compatible w/ migrate. Note, I'm using file sources for my migrations and package everything into a docker image for my API servers.
  2. Use the CLI to test the up/down migration on a test DB instance. The force command is handy for "fixing" borked migrations.
  3. Ship the API server docker image. The API server (go binary) is responsible for running migrations (up only) when starting. I rely on the db lock to prevent contention between migrations and manage migrations manually using the CLI if necessary.

@kaaquist
Copy link
Author

Thanks for your comments. I assume that the cli will create the version table on first run? Because that is what I don't get 😀 .. Do I create it my self or does the migrate app do that?

@dhui
Copy link
Member

dhui commented May 31, 2018

Correct, the table used to track the currently applied migration is created by migrate, specifically, by the db driver.

@dhui dhui closed this as completed Jun 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants