Questions tagged [flask-migrate]

Use this tag for questions related to the Flask extension flask-migrate, this extension implements SQLAlchemy database migrations. It should be used with the tag Flask too.

Flask-Migrate is an extension that handles SQLAlchemy database migrations for Flask applications using Alembic. The database operations are provided as command line arguments for Flask-Script.

Documentation is here

320 questions
2
votes
2 answers

Flask - SQLAlchemy - Add nullable=False column to existing table with data

I'm trying to add a new nullable=False column to an existing table. But it won't create the column because there are existing rows and the field is Null. It's a classic catch 22 :D. here's my model column I added: user_id = db.Column(db.Integer,…
ajbraus
  • 2,909
  • 3
  • 31
  • 45
2
votes
0 answers

Alembic execute SQL as part of migration

I want alembic to get the current stored procedure from DB compare it to the one in the code. If they are different to update the DB. I edited the env.py file to check for this, and generate an upgrade versions of the raw SQL. when running the…
Lev
  • 999
  • 2
  • 10
  • 26
2
votes
1 answer

Flask-Migrate creates the same duplicate migration when used with postgres schemas

I have a very simple and silly problem but I don't know what I'm missing. Basically, the way I've currently written my manage app, it seems flask migrate always creates an absolute migration and not just a change-set to migrate from the previous…
s5s
  • 11,159
  • 21
  • 74
  • 121
2
votes
1 answer

ModuleNotFoundError when importing package that is installed in conda environment

Unable to import flask-migrate dependencies that are missing python version/sub-version from build version (3rd column of conda list output). Flask-migrate was installed from conda-forge using: conda install -c conda-forge flask-migrate Several…
surfncdog
  • 43
  • 6
2
votes
2 answers

models are not detectable by flask migrate

I have this tree in my flask application: -- api -- migrations -- model -- __init__.py -- Persons.py -- Comments.py -- other_classes.py -- resources -- __init__.py -- app.py -- util.py This is __init_.py…
Souad
  • 4,856
  • 15
  • 80
  • 140
2
votes
0 answers

What is causing the IntegrityError 'Cannot add foreign key constraint'?

My flask app works absolutely well locally. I am deploying the app to Python Anywhere. The problem is that when I run flask db upgrade in the pythonanywhere bash I get the error below (when I do any db migration and upgrade locally there are no…
2
votes
1 answer

Flask SQL Alchemy listens_for decorator

I am trying to create a to-do list application in Flask. I have a lot of experience with Python but am fairly new to the Flask framework. I have 3 models - User, Task and Project and I would like for there to be a default project called Inbox that…
J Finer
  • 389
  • 1
  • 3
  • 10
2
votes
1 answer

How to specify a full text search index (MySQL) in an Alembic migration?

I'm using Flask-Migrate for a project in which the target database is MySQL-compatible Aurora. I added a full-text index to a model using Menzhuo's SQLAlchemy fulltext search module: class Post(db.Model, FullText, Serializable): __tablename__ =…
Ray Toal
  • 86,166
  • 18
  • 182
  • 232
2
votes
0 answers

Flask-Migrate: Table Already Exists Error

From an empty schema on postgres I'm able to create a single table (blog) using flask-migrate using: python migrate_test.py db init python migrate_test.py db migrate python migrate_test.py db upgrade This creates the table fine. Then I do the…
blountdj
  • 599
  • 1
  • 11
  • 23
2
votes
2 answers

Error on Flask-migrate with application factory

run.py db = SQLAlchemy() migrate = Migrate() def create_app(): app = Flask(__name__) db.app = app db.init_app(app) migrate.init_app(app, db) return app if __name__ == '__main__': application = create_app() …
2
votes
0 answers

Integrating Flask-APScheduler with flask-migrate and flask Script

I am not clear on how to integrate my models, using flask-script, and scheduled jobs on the same database. There appears to be some work under the hood with Flask-apscheduler where it creates the database for you. When I run python manage.py db init…
spitfiredd
  • 2,897
  • 5
  • 32
  • 75
2
votes
1 answer

Flask-SQLAlchemy how to do constraint foreign key with cascade in MySQL (InnoDB)?

I've been looking for ways to implement the CONSTRAINT FOREIGN KEY ON DELETE CASCADE in the below UsersAccessMapping model in SQLAlchemy with PyMySQL driver and MariaDB 10.0 with InnoDB in the database. Python = 3.5.2 SQLAlchemy = 1.1.13 …
Juha Untinen
  • 1,806
  • 1
  • 24
  • 40
2
votes
0 answers

Does Flask-Migrate handle manually defined sequences?

I'am building a flask-sqlalchemy data model and had success creating the tables and adding data to the tables in the database. I recently decided to include Flask-Migrate around the app so I can track changes conveniently. Using Flask-Migrate along…
2
votes
1 answer

How to call flask migrate api in script

I have a database db. I want to judge if flask_migrate has created tables in db. If not, upgrade db. There are commands, but no examples about calling migrate, upgrade in python script. The test files in flask_migrate also run commands: (o, e, s) =…
Jojo
  • 89
  • 8
2
votes
0 answers

Flask-Migrate Alter Table Error

i've been scratching my head for a bit of time now with this error and I can't seem to figure out what's wrong. Maybe you can help? Using Flask-Migrate i've modified my models and am attempting to migrate the database accordingly. The error i'm…
esreli
  • 4,993
  • 2
  • 26
  • 40