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

How to use flask-migrate with other declarative_bases

I'm trying to implement python-social-auth in Flask. I've ironed out tons of kinks whilst trying to interpret about 4 tutorials and a full Flask-book at the same time, and feel I've reached sort of an impasse with Flask-migrate. I'm currently using…
5
votes
1 answer

using flask-migrate with flask-script, flask-socketio and application factory

I'm creating an flask application with the application factory approach, but have an issue when using Flask-Migrate with socketio and flask-script. The problem is that I'm passing my create_app function to the Manager but I need to pass the app to…
Zyber
  • 1,034
  • 8
  • 19
5
votes
1 answer

Delete rows with foreign key in PostgreSQL Flask

I want to delete a row from my model which has ForeignKey with postgresql. But I got this error: IntegrityError: (IntegrityError) update or delete on table "users" violates foreign key constraint "users_bestfriend_id_fkey" on table "users" DETAIL:…
LiLi
  • 301
  • 2
  • 7
  • 21
4
votes
2 answers

Authentication failure with Flask-Migrate and SQLAlchemy 2.0

After upgrading my flask application from SQLAlchemy 1.4.46 to 2.0.1 I'm seeing that I get a password authentication failed error during flask db upgrade (Flask-Migrate). I'm able to connect fine running flask normally. DB upgrades were working…
Nolan
  • 748
  • 7
  • 11
4
votes
2 answers

Can't import MigrateCommand from flask_migrate

I made a manage.py file for database migration in a Flask application and I get an error when trying to import MigrateCommand. I'm using PyCharm and I'm sure the package is installed. Code: import os from flask_migrate import…
Spyromancer
  • 435
  • 1
  • 3
  • 10
4
votes
1 answer

flask db migrate do not change column setting

I am using sql-alchemy with flask-migrate. I set up my database class with sth like this: class Candidate(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(32), index=False, unique=False) interviewer =…
Emil Haas
  • 484
  • 3
  • 17
4
votes
1 answer

Alembic cannot be cast automatically to type integer

I had a model like this: class Schedule(db.Model): __tablename__ = 'schedule' id = db.Column(db.Integer, primary_key=True) student_id = db.Column(ARRAY(db.Integer, db.ForeignKey('student.id'))) Then I change the student_id column to be…
Tri
  • 2,722
  • 5
  • 36
  • 65
4
votes
1 answer

Flask-migrate: change model attributes and rename corresponding database columns

I have a bit of experience with Flask but not very much with databases (Flask-migrate / alembic / SqlAlchemy). I'm following this tutorial and things are working quite alright. I have a User model like this: # user_model.py from app import DB ...…
Tommy
  • 628
  • 11
  • 22
4
votes
6 answers

ModuleNotFoundError: No module named 'flask_migrate'

I'm new to python+flask, and wanted to use flask to create a website. The IDE is Visual studio 2017, and I could run the program successfully with flasky.py as startup file. But in CLI, I constantly got this error. (sms)…
maorui2k
  • 43
  • 1
  • 1
  • 4
4
votes
1 answer

Correct way to register flask admin views with application factory

I am using an application factory to add views to my flask application like so : (this is not my actual application factory, and has been shortened for the sake of brevity) def create_app(config_name='default'): app = Flask(__name__,…
4
votes
1 answer

Getting Flask-Migrate to Ignore SQL Views that are mapped as Flask-SQLAlchemy Models

I am using Flask-SQLAlchemy to define my models, and then using Flask-Migrate to auto-generate migration scripts for deployment onto a PostgreSQL database. I have defined a number of SQL Views on the database that I use in my application like below.…
Andy G
  • 820
  • 1
  • 8
  • 11
4
votes
1 answer

How to create order by index in flask-sqlalchemy

There are the following: Flask, Flask-sqlalchemy, Flask-migrate There is a class describing the table: class Student(db.Model): __tablename__ = 'student' id = db.Column(db.Integer, primary_key=True) first_name =…
4
votes
2 answers

Flask-Migrate "No section: 'alembic'" on "db migrate" command

I'm using Flask-Migrate, and I'm trying to add a column to my database by using the db migrate command. Here is the setup: from flask import Flask, render_template, request, session, flash, redirect, url_for from flask.ext.babel import Babel from…
b_g
  • 299
  • 1
  • 4
  • 14
3
votes
1 answer

Is it possible to drop a unique constraint from a column?

I've tried simply removing the unique=True constraint and running flask db migrate flask db upgrade in the command line but when I run my flask app I'm still getting a (sqlite3.IntegrityError) UNIQUE constraint failed error. Is there a simple way…
kenavuen
  • 51
  • 1
  • 6
3
votes
2 answers

Flask Migrate (Alembic) Not Creating Migrations

I have a fairly large Flask app, and my typical workflow to create new data tables is as follows: I create a class in models.py, such as the below: class ExampleModel(db.Model): __tablename__ = 'example_table' id = db.Column(db.Integer,…