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
14
votes
4 answers

flask-migrate doesn't detect models

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…
kurtgn
  • 8,140
  • 13
  • 55
  • 91
14
votes
7 answers

Flask - ImportError: No module named migrate.versioning

I'm working through a flask tutorial and am trying to run a script that creates a database instead of doing it through the command line. It uses the SQLAlchemy-migrate package, but when I try to run the script, it gives an ImportError. This is the…
Takeshi Patterson
  • 1,207
  • 6
  • 15
  • 29
13
votes
3 answers

Flask Migrate "ValueError: Constraint must have a name"

I have created a flask migrate script ,however, when I running the upgrade function, I get the following error: INFO [alembic.runtime.migration] Context impl SQLiteImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO …
Saif
  • 422
  • 5
  • 19
12
votes
1 answer

How to autoimport module in flask-migrate migration

My flask project uses sqlalchemy_utils in some of its model definitions, which causes migration errors like: NameError: global name 'sqlalchemy_utils' is not defined due to this package not being imported in the migration files. I'd like to have…
David Simic
  • 2,061
  • 2
  • 19
  • 33
12
votes
3 answers

How do I split Flask models out of app.py without passing db object all over?

I'd like to use Flask-Migrate and am looking at their example: from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.script import Manager from flask.ext.migrate import Migrate, MigrateCommand app =…
NewGuy
  • 3,273
  • 7
  • 43
  • 61
11
votes
5 answers

How to check if there are pending migrations when using SQLAlchemy/Alembic?

We're using SQLAlchemy and Alembic (along with Flask-SQLAlchemy and Flask-Migrate). How to check if there are pending migrations? I tried to check both Alembic's and Flask-Migrate's documentation but failed to find the answer.
arikfr
  • 3,311
  • 1
  • 25
  • 28
10
votes
1 answer

Flask database migrations on heroku

With my app I am using flask-script and flask-migrate for database migrations, everything works locally. When, I run heroku run python manage.py db init It creates this output: Running python manage.py db init on ⬢ fpds-scheduler... up, run.1290…
spitfiredd
  • 2,897
  • 5
  • 32
  • 75
10
votes
5 answers

Flask-Migrate hangs on table modificiation

I have an issue on running the upgrade command with Flask-Migrate. Originally I was trying to modify three tables at once and it hung, I narrowed it down to a specific table (the other upgrades worked without issue). I don't see any locks on the…
Sobigen
  • 2,038
  • 15
  • 23
9
votes
3 answers

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

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, …
Alex
  • 615
  • 8
  • 26
9
votes
1 answer

Work on multiple branches with Flask-Migrate

I'm using Flask-Migrate (Alembic) to manage SQLAlchemy database migrations. I'm working on two different branches with different migrations. If I switch branches, I get an error that the migration is not found. If i merge this branches into the…
Anna
  • 545
  • 5
  • 10
9
votes
1 answer

using flask-migrate with flask-script and application factory

I'm building flask application and decided to try application factory approach this time, but got into trouble with flask-migrate and can't figure out simple solution. Please note that I want to pass config location as an option to the…
ETK
  • 115
  • 2
  • 5
8
votes
4 answers

Running flask-migrate on heroku produces error

I'm trying to use flask-migrate to version my database locally and then reflect the changes in production (Heroku). So far I managed to successfully version the local database and upgrade it, so now I wanted to reflect this on Heroku. To do this I…
lawicko
  • 7,246
  • 3
  • 37
  • 49
7
votes
1 answer

Flask-Migrate - 'Please edit configuratio/connection/logging settings' on 'flask db init'

Have spent literally the past three days trying to figure this out and just can't seem to get it. Have reviewed other posts here and elsewhere regarding the same issue (see here, here, here, among others) countless times and am apparently just too…
7
votes
2 answers

Change alembic logger

We are using alembic to apply DB revision. I have configured the connection and it works as expected, except I am not able to make it use our customer logger. We have our own logger class (derived from Python logging) which is used throughout the…
PyRaider
  • 607
  • 4
  • 11
  • 21
7
votes
3 answers

How to run flask_migrate in Docker

I have a project with the following structure: proj src application app.py manage.py migrations Dockerfile docker-compose.yaml My goal is to run migrations from the application directory to create tables in the database…
maslak
  • 1,115
  • 3
  • 8
  • 22
1
2
3
21 22