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
3
votes
0 answers

Flask migration is not applying on all tables

i have a project where i create four tables (users,products, agents, customer) when i do migration with: flask db init, flask db migrate, flask db upgrade, only users and products get migrated here it is the structure of my project: my code for…
3
votes
1 answer

Flask-migrate drops tables created by Celery

I have a flask app that is connected to a PostgreSQL database. I integrated celery and configured its result back-end to be the same postgresql database. Celery automatically created two tables (Task and TaskSet) in the database. Other tables that…
Lawynn Jana
  • 88
  • 1
  • 5
3
votes
2 answers

Cannot run entrypoint script in Docker with Flask and Flask Migrate, even though it works in Terminal

I have a Flask API that connects to an Azure SQL database, deployed on Azure App Service in a Docker Image. It works fine but I am trying to keep consistency between my development, staging and production environments using Alembic/Flask-Migrate to…
jzia
  • 61
  • 6
3
votes
1 answer

flask-migrate/alembic fails with `ValueError: not enough values to unpack (expected 2, got 1)` when running db migrate

I have created a Flask app which currently has around ~30 models. So far, when I was testing everything locally, I had a local Postgresql docker container on which I would use SQLAlchemy().create_all() to create all tables. That worked great so far.…
Moshe Vayner
  • 738
  • 1
  • 8
  • 23
3
votes
2 answers

Flask Migration: Problem creating table and using existing Enum in database. `create_type=False` Do not work

I am using flask-migrate, SQLAlchemy and alembic to manage my database. I want to create a new table in the database. The new table has a column which uses an existing Enum. I have read on many SO questions that you can use an existing Enum with…
DarioB
  • 1,349
  • 2
  • 21
  • 44
3
votes
1 answer

Using Flask-Migration in development and deployment

I've been looking through the stackoverflow posts on flask development regarding database migrations using Flask-Migrate. Yet I'm still not satisfied and left pondering for the best practice on database migration for managing development and…
3
votes
1 answer

SQLAlchemy migration table already exist

I just got started using flask-migrate and I encounter some problems with it. In order to get myself familiarized with it, I started a new project with a mock MySQL database. I run the migration as following export FLASK_APP=run.py flask db…
Terchila Marian
  • 2,225
  • 3
  • 25
  • 48
3
votes
2 answers

How to setup Flask-Migrate with the correct database reference?

I am building a flask app and am trying to set up database migration using Flask-Migrate. I have gotten it working kind of, but have a weird issue of the app/migrate not looking in the same place for the .db file and need to know how to how to get…
chfaber
  • 73
  • 5
3
votes
1 answer

How to add MigrateCommand while using flask built in cli?

Earlier while using Manager from flask_script we can add command to Manager like this. from flask_migrate import Migrate, MigrateCommand from flask_script import Manager manager = Manager(app) manager.add_command('db', MigrateCommand) Now in this…
Ciasto piekarz
  • 7,853
  • 18
  • 101
  • 197
3
votes
1 answer

database migration in flask - sqlalchemy

flask-restplus and sqlalchemy to design my backend. I am using flask-migrate library so that I can adjust my database tables when there is any such requirements. Here is my directory structure -mainfolder/ -app/ -v1/ …
handsomer223
  • 885
  • 4
  • 12
  • 16
3
votes
2 answers

How do I find the latest migration created w/ flask-migrate?

My flask application now has 20+ migrations built with flask-migrate and they all have hashed file names like: 389d9662fec7_.py I want to double check the settings on the latest migration that I ran, but don't want to open every file to look for the…
rykener
  • 711
  • 1
  • 6
  • 16
3
votes
0 answers

flask-migrate for multi-tanent postgres database

In my flask project I wrote on my manage.py file: from app import app, db from flask_script import Manager, Shell from flask_migrate import Migrate, MigrateCommand migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db',…
Emu
  • 5,763
  • 3
  • 31
  • 51
3
votes
2 answers

Flask Sql-alchemy not dropping tables created by alembic

I have flask application with Flask-migrate. Running db upgrade creates following tables: List of relations Schema | Name | Type | Owner -------+-----------------+-------+---------- public | alembic_version | table |…
3
votes
2 answers

SQLAlchemy configration for MySQL's "SET foreign_key_checks = 0"

I am using SQLAlchemy with Flask to create database tables - every table has at least one foreign key - it works with sqlite but not MySQL - I get foreign key integrity error when creating the tables in MySQL (the parent table is not created when…
dami.max
  • 377
  • 3
  • 17
3
votes
2 answers

Alembic/Flask-Migrate not detecting after_create events

I have a simple Flask-SQLAlchemy model (with event listener to create trigger): from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class Confirm(db.Model): created = db.Column(db.DateTime, default=db.func.current_timestamp(),…