-
-
Notifications
You must be signed in to change notification settings - Fork 226
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
Change from Integer to String not detected. #24
Comments
There is not something this extension does, I'm simply invoking Alembic for the migration work. See my answer to a similar question in StackOverflow: http://stackoverflow.com/a/17246043/904393. There you can see what Alembic supports and does not support when generating migrations. Column type changes are not supported in the default configuration, but can be enabled. |
Thanks @miguelgrinberg! That makes sense.
But how would you use it in the context of Flask-Migrate? Doesn't Flask-Migrate add it's own settings to Alembic? |
You have to edit function
|
I added the compare_type parameter to my env.py but it is still not recognizing the change in one of my column data types. Is there something else I need to do? I'm working within a virtual env if that matters. |
Have you read the documentation? Type comparison is not always accurate. You can customize it if necessary. My recommendation, however, is that you edit the migration script by hand. You always need to review migration scripts anyway, so it costs you little to hand edit the type changes. |
Alright, guess I need to learn how to do that anyway. Thanks! |
I also leave this here for other n00bs that come across this thread: I was editing the env.py file in the Flask-Migrate package. I needed to edit the env.py in my migrations directory that is created after you run the init command. |
Yes, that is correct. The |
@davedg629 I add the compare_type args in my env.py, which is created after I ran the init command, but it still did not work. When I was using alembic directly, changing the compare_type arg worked. |
You can now add |
One more note for posterity, SQLite does not support changing the type of a column. Period. You will always get syntax errors. |
Thanks atomicwrites. So the manual approach is best then i gather. |
Well if you're using SQLite you can't change the type of a column wether or not you use alembic. It's a limitation of SQLite (thing like this are where the "lite" comes in). You have to either make a new column or jugle with copying into a new table. |
I have a column:
code = db.Column(db.Integer(unsigned=True,zerofill=True))
And when I change that column from
Integer
toString
like so:code = db.Column(db.String())
And I run:
python manage.py db migrate
the migration does not detect any changes.
Should it not detect at least a change in the column data type?
Migration looks like this after:
The text was updated successfully, but these errors were encountered: