Avoid describing twice in migration scripts
I'm pretty new with alembic, but I use it for the migration of my production database at work.
I often need to migrate data, so I have to hack a bit the auto generated script. However, I need to describe my change twice:
- first, I reuse the operation stuff generated by the autogenerate option does its job:
op.create_table('the_new_table', sa.Column(...)) op.create_column(...)
- second, I need to fill this table. Since I need SQLAlchemy object, I need to redescribe it again:
the_new_table = sa.Table('the_new_table', sa.MetaData(), sa.Column(...))
Note: I needed to use sa.Table in order to have the autoincrement working, because I didn't wanted to work with a sa.sql.table object...
and then I can use execute/select/insert/... on the the_new_table.c object.
I have two solutions to propose: 1. let op.create_table,... accept sa.sql.table or sa.Table objects 2. return a sa.sql.table (or sa.Table) object after create_table.
Or if neither solution is correct, can you enhance the documentation (and the tutorial) to fulfill this use case?
This should be the same for create_column.
Many thanks. Gaetan