I'm using sqlalchemy_utils to add a "choices" field to my database. And after I ran my migrate using Flask Migrate, it converts all my choices into 255, below is a simplified example:
# models.py
from sqlalchemy_utils.types.choice import ChoiceType
class Stuff(db.Model):
type = db.Column(ChoiceType(Stuff_types))
After running manage.py migrate
, the migration file looks like:
# /migrations/versions/1234migrate.py
import sqlalchemy_utils
def upgrade():
sa.Column('type', sqlalchemy_utils.types.choice.ChoiceType(length=255), nullable=False),
I manually changed those length=255
into the correct types(in this case stuff_types
), and it worked. I wonder if I did not set up alemic correctly to work with sqlalchemy_utils. Or if there is a better solution that I'm not aware of?
Thanks guys!