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

280 questions
55
votes
4 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,396
  • 2
  • 22
  • 32
54
votes
4 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
  • 26,790
  • 23
  • 85
  • 150
42
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
  • 451
  • 1
  • 4
  • 7
38
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',…
25
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
  • 26,790
  • 23
  • 85
  • 150
21
votes
4 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…
19
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,432
  • 5
  • 17
  • 27
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,273
  • 3
  • 16
  • 34
17
votes
4 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
  • 481
  • 1
  • 6
  • 15
16
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
  • 189
  • 1
  • 1
  • 8
15
votes
10 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
  • 1,664
  • 2
  • 13
  • 28
15
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 =…
14
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
  • 5,399
  • 12
  • 46
  • 95
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…
13
votes
1 answer

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
  • 8,204
  • 16
  • 60
  • 102
1
2 3
18 19