Setup:
mysql> SELECT version();
* 5.7.27-0ubuntu0.18.04.1
* Python 3.6.8
* SQLAlchemy 1.3.6
* Alembic 1.0.11
models.py:
class Experiments(db.Model):
id = db.Column(db.Integer, primary_key=True)
# country = db.Column(db.String(100))
countryland = db.Column(db.String(100))
insert_date = db.Column(db.DateTime, index=True,
default=datetime.utcnow)
SQL data:
INSERT INTO experiments (country)
VALUES ('US'),
('Canada'),
('Mexico'),
('Brazil'),
('Argentina'),
('Spain'),
('Portugal'),
('France'),
('Germany'),
('UK');
migration file:
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
# op.add_column('experiments', sa.Column('countryland', sa.String(length=100), nullable=True))
# op.drop_column('experiments', 'country')
op.alter_column('experiments', column_name='country', new_column_name='countryland')
# ### end Alembic commands ###
Problem:
I want to rename the column name from "country" to "countryland". But I'm getting this error in my terminal can anybody help me please?
$ flask db upgrade
[2019-08-27 11:43:26,155] INFO in __init__: microblog startup
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade 1f866a4fa5a0 -> 69e7cfcf87f1, Testing column rename 02.
ERROR [root] Error: All MySQL CHANGE/MODIFY COLUMN operations require the existing type.
Electronically yours,
Mike