My database is MySQL. I use SqlAlchemy ORM to define and access it. I use Alembic for migrations. I have a model with a field that used to contain just English text (Ascii/latin-1). Now, this field needs to contain Unicode text. In order to convert my model to support Unicode for MySQL I need to add the following class level attribute: mysql_character_set = 'utf8'
class MyModel(Base):
__tablename__ = 'mymodel'
mysql_character_set = 'utf8'
id = Column(Integer, primary_key=True)
name = Column(String(64), unique=True, nullable=False)
So far so good. I want to add this attribute as part of an Alembic migration script. I normally use Alembic's excellent auto-generate command:
alembic revision --autogenerate
The problem is that this command doesn't capture every model change and in particular not the addition of the mysql_character_set attribute.
How do I add this attribute manually to the alembic migration script?