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
6
votes
8 answers

Unable to find source of: ERROR [root] Error: Can't locate revision identified by '..'

I am trying to run migrations from command line and keep getting error: ERROR [root] Error: Can't locate revision identified by 'faf3ebfbe667' As suggested in other posts I deleted my sqlite db and migration folder (several times). I recreated…
GeoMeteoMe
  • 161
  • 1
  • 1
  • 9
6
votes
3 answers

Flask-Migrate `db upgrade` fails with "relation does not exist"

I'm working in a development environment on a flask-app with a Postgres 10 database that has ~80 tables. There are lots of relationships and ForeignKeyConstraints networking it all together. It was working fine with Flask-Migrate. I'd bootstrapped…
Bob Jordan
  • 3,049
  • 2
  • 34
  • 41
6
votes
2 answers

Flask-Migrate not detecting tables

I have the following project structure: project/__init__.py from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate db = SQLAlchemy() migrate = Migrate() def create_app(): app = Flask(__name__) …
Joe
  • 175
  • 2
  • 11
6
votes
3 answers

How to run/invoke a flask cli command programmatically?

I am using python 3 and flask, with flask-migrate (which uses alembic) to handle my SQL migrations. When I run local integration tests, I want to rebuild the database each time so I can run my API calls against a clean db for each api call i'm…
Sam Adams
  • 5,327
  • 2
  • 18
  • 17
6
votes
1 answer

Run app from Flask-Migrate manager

I used these lines to start my application: from app import app app.run(host='0.0.0.0', port=8080, debug=True) Using Flask-Migrate, I have this instead: from app import manager manager.run() manager.run does not take the same arguments as app.run,…
rablentain
  • 6,641
  • 13
  • 50
  • 91
6
votes
1 answer

Error at migrating in Flask with sqlalchemy_utils ChoiceType

I have a Flask model: class User(db.Model): ROLE_USER = 0 ROLE_MODERATOR = 1 ROLE_ADMIN = 2 ROLES = [ (ROLE_USER, u'Regular user'), (ROLE_MODERATOR, u'Moderator'), (ROLE_ADMIN, u'Admin') ] id =…
AKhimself
  • 165
  • 1
  • 11
6
votes
2 answers

can not rename column using alter_column

I have an existing project that is based on pylons and sqlalchemy. I did not use alembic or any wrapper in this project, yet. I migrated the project to flask and sqlalchemy. I took the old database of the old version 1.5 and generated the first…
cornelinux
  • 877
  • 1
  • 9
  • 17
6
votes
1 answer

Why is Flask-Migrate making me do a 2-steps migration?

I'm working on a project with Flask, SQLAlchemy, Alembic and their wrappers for Flask (Flask-SQLAlchemy and Flask-Migrate). I have four migrations: 1c5f54d4aa34 -> 4250dfa822a4 (head), Feed: Countries 312c1d408043 -> 1c5f54d4aa34, Feed:…
cuducos
  • 730
  • 6
  • 17
5
votes
1 answer

Flask-Migrate/Alembic not detecting models using base class and multi-file structure

This question has been asked a million times but none of the solutions seem to be working for me. I should note I've dealt with tangential issues quite often in other projects Currently I'm using flask-sqlalchemy, flask-migrate, and postgresql. File…
mas
  • 1,155
  • 1
  • 11
  • 28
5
votes
1 answer

Using Flask-migrate for models in multiple files

I am confused about how to use Flask-Migrate when I have multiple models. Basically my Flask app looks like this: app ├── __init__.py ├── config.py ├── manage.py ├── migrations ├── models │   ├── model1.py │   ├── model2.py ├── resources ├──…
a_corn
  • 75
  • 2
  • 6
5
votes
7 answers

Flask-Migrate command 'flask db init' can't find app file

Firstly, I'm following the Python Flask tutorial posted here: https://scotch.io/tutorials/build-a-crud-web-app-with-python-and-flask-part-one. Everything was working smoothly up to the 'Migration' section where executing: $ flask db init ... failed…
mcorrigal
  • 101
  • 1
  • 1
  • 5
5
votes
1 answer

Can you copy/move data between columns in a DB migration file?

I have a SqlAlchemy/Flask application. In it, I have an existing model named MyModelA. This is what it looks like: class MyModelA(db.Model): a_id = db.Column(db.Integer, nullable=False, primary_key=True) my_field1 =…
Saqib Ali
  • 11,931
  • 41
  • 133
  • 272
5
votes
1 answer

Flask Migrate using different postgres schemas ( __table_args__ = {'schema': 'test_schema']})

I'm trying to use flask, sqlalchemy, and flask_migrate... But every time run manage.py migrate, alembic always detect my model as a new table. I think that i put table_args in my model to store table in a different postgres schema: class…
5
votes
2 answers

how to set unique value for each row on alembic migration

I added a unique attribute uid for MyModel model: class MyModel(db.Model): ... uid = db.Column(db.String(50), nullable=False) ... __table_args__ = (UniqueConstraint('uid', name='unique_uid'),) I have a migration: def upgrade(): …
Alexey Egorov
  • 2,221
  • 2
  • 18
  • 21
5
votes
4 answers

How can I use Flask-migrate across multiple development environments

I have flask-migrate (version 1.8.0) working well with a sqlite database in a development environment. Now I would like to migrate our data to MySQL and maintain all of our migration history (so it stays in sync with our Flask-SQLAlchemy models in…
AmZar
  • 71
  • 1
  • 3
1 2
3
21 22