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
82
votes
5 answers

Could not assemble any primary key columns for mapped table

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…
Michael Samoylov
  • 2,933
  • 3
  • 25
  • 33
65
votes
5 answers

Creating seed data in a flask-migrate or alembic migration

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 """ #…
Mark Richman
  • 28,948
  • 25
  • 99
  • 159
56
votes
2 answers

sqlalchemy postgresql enum does not create type on db migrate

I develop a web-app using Flask under Python3. I have a problem with postgresql enum type on db migrate/upgrade. I added a column "status" to model: class Banner(db.Model): ... status = db.Column(db.Enum('active', 'inactive', 'archive',…
51
votes
4 answers

Why Flask-migrate cannot upgrade when drop column

I am using SqlAlchemy and Flask-migrate for DB migration. I have successfully init the DB and upgrade once, but when I deleted one of my table column, I managed to migrate however upgrade gave me the following error: sqlalchemy.exc.OperationalError:…
Cunpei Nan
  • 541
  • 1
  • 4
  • 7
39
votes
12 answers

CommandError: Can't locate revision identified by '...' when migrating using Flask-Migrate

I started using Flask-Migrate today and installed it on a test project. However i am getting following error: alembic.util.exc.CommandError: Can't locate revision identified by 'e39d16e62810' Steps to reproduce: run "python create_db.py" run…
Tobias Marschall
  • 2,355
  • 3
  • 22
  • 40
38
votes
6 answers

sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string

I'm learning flask web microframework and after initialization of my database I run flask db init I run flask db migrate, to migrate my models classes to the database and i got an error. I work on Windows 10, the database is MySQL, and extensions…
28
votes
6 answers

Flask-Migrate not creating tables

I have the following models in file listpull/models.py: from datetime import datetime from listpull import db class Job(db.Model): id = db.Column(db.Integer, primary_key=True) list_type_id = db.Column(db.Integer,…
Mark Richman
  • 28,948
  • 25
  • 99
  • 159
27
votes
7 answers

Flask says "did not provide the FLASK_APP environment variable"

I'm trying to run a Flask application with flask run but no matter what, I receive this error: Error: Could not locate Flask application. You did not provide the FLASK_APP environment variable. I'm using virtualenv in my project and I'm running the…
rosendin
  • 611
  • 1
  • 10
  • 18
26
votes
10 answers

Flask-Migrate No Changes Detected to Schema on first migration

I'm using Flask with Flask-SQLAlchemy and Flask-Migrate to create an application, however when I try to create a migration nothing happens. I've created two tables in app/models.py: from flask import current_app from . import db class…
J Finer
  • 389
  • 1
  • 3
  • 10
25
votes
3 answers

In Flask-migrate ValueError: invalid interpolation syntax in connection string at position 15

I am using flask migrate to for database creation & migration in flask with flask-sqlalchemy. Everything was working fine until I changed my database user password contains '@' then it stopped working so, I updated my code based on Writing a…
anils
  • 1,782
  • 6
  • 19
  • 29
20
votes
4 answers

SQLAlchemy + alembic: create schema migration

I'm not sure how to define a create schema foo migration? My Model looks like this (I'm using Flask-Migrate): class MyTable(db.Model): __tablename__ = "my_table" __table_args__ = {"schema": "foo"} id = ColumnPrimKey() name =…
s5s
  • 11,159
  • 21
  • 74
  • 121
18
votes
8 answers

Cannot complete Flask-Migration

I've setup a local Postgres DB with SQLAlchemy and cannot commit my first entry. I keep on getting this error... ProgrammingError: (ProgrammingError) relation "user" does not exist LINE 1: INSERT INTO "user" (name, email, facebook_id,…
Suraj Kapoor
  • 1,615
  • 4
  • 22
  • 34
17
votes
2 answers

How do you add migrate an existing database with alembic/flask-migrate if you did not start off with it?

This is the chain of events that has and is happening Day 0: I developed and deployed my app Day 1: I create the new database Day 3: I realized I wanted to add a new row to my existing table. I found flask-migrate and I want to use it to migrate…
Tinker
  • 4,165
  • 6
  • 33
  • 72
17
votes
4 answers

Can't migrate or upgrade database with Flask-Migrate (Alembic)

I've been using Flask-Migrate (Alembic) for updating my database. I updated my models.py file however I made an error. I ran a migration and went to upgrade the database, however I got this error: sqlalchemy.exc.IntegrityError:…
Pav Sidhu
  • 6,724
  • 18
  • 55
  • 110
16
votes
3 answers

Flask-Migrate sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column

I am using Flask-Migrate in my application, with the following models: listpull/models.py from datetime import datetime from listpull import db class Job(db.Model): id = db.Column(db.Integer, primary_key=True) list_type_id =…
1
2 3
21 22