简体   繁体   中英

SQLAlchemy Migrate - Can I add (or modify) a column to a certain position of an existing table?

I want to add a column to a certain position of an existing table or move one of the columns. But I can't find any method in Sqlalchemy-migrate.

I want to know methods equivalent following MySQL queries in sqlalchemy-migrate

ALTER TABLE tablename ADD column_name2 INT AFTER column_name1
ALTER TABLE tablename ADD column_name2 INT FIRST
ALTER TABLE tablename MODIFY COLUMN column_name2 INT AFTER column_name1;

You need to follow below steps:

  1. create temp table,
  2. copy records in temp table
  3. rename temp to original table.

During ALTER operation flow as well, these operation will be executed internally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM