flask-migrate

How to add a new column after another existing column in flask-migrate?

How to add a new column after another existing column in flask-migrate? Question: flask-migrate detected my column changes and was able to successfully create and execute the migration. def upgrade(): # ### commands auto generated by Alembic – please adjust! ### with op.batch_alter_table(‘vtuber_info’, schema=None) as batch_op: batch_op.add_column(sa.Column(‘model’, sa.VARCHAR(length=128), server_default=”, nullable=False, comment=’model info’)) However, I found …

Total answers: 1

Why Flask Migrations does not detect a field's length change?

Why Flask Migrations does not detect a field's length change? Question: I have the following model, I want to change the length of name, when I do the migration it does not detect the changes class Client(db.Model): __tablename__ = “client” client_id = db.Column( db.Integer, primary_key=True, autoincrement=True ) name = db.Column(db.String(65)) email = db.Column(db.String(255)) For example …

Total answers: 2

flask-migrate doesn't detect models

flask-migrate doesn't detect models Question: I am reading (and watching) about Flask-Migrate here: https://realpython.com/blog/python/flask-by-example-part-2-postgres-sqlalchemy-and-alembic/ and here https://www.youtube.com/watch?v=YJibNSI-iaE#t=21 and doing everything from this tutorial: I started a local postgres server (using Postgres.App, which started the server at postgresql://localhost:5432) updated configs as per said tutorial updated app.py, created a models.py etc. After you install Flask-Migrate and run …

Total answers: 4

Could not assemble any primary key columns for mapped table

Could not assemble any primary key columns for mapped table Question: When I’m trying to create a database schema migration, I’m getting this weird error. Can you please help me to figure out what’s wrong? $ python app.py db upgrade [skipped] sqlalchemy.exc.ArgumentError: Mapper Mapper|EssayStateAssociations|essay_associations could not assemble any primary key columns for mapped table ‘essay_associations’ …

Total answers: 5

Creating seed data in a flask-migrate or alembic migration

Creating seed data in a flask-migrate or alembic migration Question: How can I insert some seed data in my first migration? If the migration is not the best place for this, then what is the best practice? “””empty message Revision ID: 384cfaaaa0be Revises: None Create Date: 2013-10-11 16:36:34.696069 “”” # revision identifiers, used by Alembic. …

Total answers: 5