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

Use Alembic for migrations #801

Merged
merged 1 commit into from
Jul 31, 2015
Merged

Conversation

ihodes
Copy link
Member

@ihodes ihodes commented Jul 30, 2015

Fixes #776
cc @danvk

Review on Reviewable

@ihodes ihodes changed the title Use Alembic for migrations WIP Use Alembic for migrations Jul 30, 2015
@ihodes ihodes force-pushed the issue-776-use-alembic-for-migrations branch 4 times, most recently from 5239566 to b5931ee Compare July 30, 2015 20:56
@ihodes ihodes changed the title WIP Use Alembic for migrations Use Alembic for migrations Jul 30, 2015
@ihodes ihodes assigned danvk and unassigned armish Jul 31, 2015
@danvk
Copy link
Contributor

danvk commented Jul 31, 2015

I'm not too familiar with Alembic. Could you walk me through what a database migration looks like in this new world?


Review status: 0 of 11 files reviewed at latest revision, 6 unresolved discussions, all commit checks successful.


alembic/env.py, line 1 [r1] (raw file):
Is this file also boilerplate that's copied from somewhere? Worth noting if so.


alembic/versions/README.md, line 1 [r1] (raw file):
Will migrations be committed? Just say "contains" then, I doubt we'll remember to update the tense once it happens :)


DEVELOP.md, line 58 [r1] (raw file):
It's not clear to me if this comment is explaining what the Python script does, or if it's something that I'm supposed to do before running this script.


DEVELOP.md, line 200 [r1] (raw file):
"a simple migration" → "a simple migration" or "simple migrations"


schema.py, line 3 [r1] (raw file):
Does import * not also import sql?


scripts/init_db.py, line 43 [r1] (raw file):
Where does this store the "stamp"?


Comments from the review on Reviewable.io

@ihodes ihodes force-pushed the issue-776-use-alembic-for-migrations branch from b5931ee to a5f3c13 Compare July 31, 2015 15:18
@ihodes
Copy link
Member Author

ihodes commented Jul 31, 2015

The steps are 1) Make a migration script containing the migration instructions for the change 2) Run the script using alembic. Alembic keeps track of which upgrades you've run by tracking the most recent migration's GUI in the DB (the "stamp" you ask about below). cf http://alembic.readthedocs.org/en/latest/tutorial.html#create-a-migration-script for a short concrete example.


Review status: 0 of 11 files reviewed at latest revision, 6 unresolved discussions, all commit checks successful.


alembic/env.py, line 1 [r1] (raw file):
It's just a file generated by Alembic, and then modified by me to work for us, not copied.


alembic/versions/README.md, line 1 [r1] (raw file):
Sure—honestly this can go away when we add a script here, some file was just needed here to keep the directory. I'll change it to a .keep file or something.


DEVELOP.md, line 58 [r1] (raw file):
I'll just remove this comment; the script itself does this check.


DEVELOP.md, line 200 [r1] (raw file):
You confused me for a second :) Fixed


schema.py, line 3 [r1] (raw file):
It does not, but it does import func, which is all I needed from sql!


scripts/init_db.py, line 43 [r1] (raw file):
In the database (cf. explanation above)


Comments from the review on Reviewable.io

@danvk
Copy link
Contributor

danvk commented Jul 31, 2015

Cool, this seems relatively painless & a clear win over our current manual process.

What's the migration process from our current Alembic-less setup to the new world? Let's do a Cycledash deploy & get this in place today before we all start going on vacation.


Review status: 0 of 11 files reviewed at latest revision, 2 unresolved discussions, some commit checks broke.


scripts/init_db.py, line 2 [r2] (raw file):
So necessry! (sp)


scripts/init_db.py, line 43 [r1] (raw file):
It's in a separate table in the DB?


Comments from the review on Reviewable.io

@ihodes
Copy link
Member Author

ihodes commented Jul 31, 2015

What's the migration process from our current Alembic-less setup to the new world?

There is no migration process whatsoever!


Review status: 0 of 11 files reviewed at latest revision, 1 unresolved discussion, some commit checks pending.


scripts/init_db.py, line 43 [r1] (raw file):
Yep, alembic_version


Comments from the review on Reviewable.io

@ihodes ihodes force-pushed the issue-776-use-alembic-for-migrations branch from a5f3c13 to d4eca99 Compare July 31, 2015 17:17
@ihodes ihodes force-pushed the issue-776-use-alembic-for-migrations branch from d4eca99 to 22a8940 Compare July 31, 2015 17:56
ihodes added a commit that referenced this pull request Jul 31, 2015
@ihodes ihodes merged commit b1c2aca into master Jul 31, 2015
@ihodes ihodes deleted the issue-776-use-alembic-for-migrations branch December 23, 2015 16:53
@hammer hammer unassigned danvk Feb 8, 2016
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

Successfully merging this pull request may close these issues.

None yet

3 participants