CommandError: Can’t locate revision identified by ‘…’ when migrating using Flask-Migrate

you delete the migration directory but the version has been saved in the database, so you have to delete the version info in the dabase, run delete from alembic_version; in mysql shell. As suggested by @mirekphd, If this is a developing environment or a single app for test, just delete it, Else BACKUP the data … Read more

Why Flask-migrate cannot upgrade when drop column

SQLite does not support dropping or altering columns. However, there is a way to work around this by making changes at the table level: https://www.sqlite.org/lang_altertable.html And more usefully for Alembic/Flask-Migrate users, Alembic’s batch_alter_table context manager lets you specify the changes in a natural way, and does a little “make new table – copy data – … Read more

sqlalchemy postgresql enum does not create type on db migrate

I decided on this problem using that. I changed the code of migration, and migration looks like this: from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql def upgrade(): banner_status = postgresql.ENUM(‘active’, ‘inactive’, ‘archive’, name=”banner_status”) banner_status.create(op.get_bind()) op.add_column(‘banner’, sa.Column(‘status’, sa.Enum(‘active’, ‘inactive’, ‘archive’, name=”banner_status”), nullable=True)) def downgrade(): op.drop_column(‘banner’, ‘status’) banner_status = postgresql.ENUM(‘active’, ‘inactive’, ‘archive’, … Read more

Creating seed data in a flask-migrate or alembic migration

Alembic has, as one of its operation, bulk_insert(). The documentation gives the following example (with some fixes I’ve included): from datetime import date from sqlalchemy.sql import table, column from sqlalchemy import String, Integer, Date from alembic import op # Create an ad-hoc table to use for the insert statement. accounts_table = table(‘account’, column(‘id’, Integer), column(‘name’, … Read more

Could not assemble any primary key columns for mapped table

You get this error because you have trailing commas after your Column() definitions, which cause application_essay_id and theme_essay_id to each be parsed as a one-element tuple containing a Column instead of just a Column. This stops SQLAlchemy from “seeing” that the columns are present, and consequently causes your model not to contain any primary key … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)