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

Flask DB migrate to support multiple databases using binds

I am using Flask Application with flask-migrate. I have initialized the app with single database but now the requirement is to add multiple databases. Here are the steps that I followed with the below code :- from flask import Flask from…
sarbjit
  • 3,786
  • 9
  • 38
  • 60
2
votes
2 answers

Flask Migrate and PostgreSQL data update

I am currently setting up a project that is based on Python Flask (with Flask Migrate) with a PostgreSQL DB. I am working in a small team and have some questions regarding database updates. As far as I am aware, If I update the database schema in…
Jon K
  • 99
  • 2
  • 9
2
votes
1 answer

flask db init returns "sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table"

I've been working on a web app in flask using an sqlite database. This has been going fine so far, and I am aware of the fact sqlite is limited in terms of alterations to tables once a database exists. However, so far i have been able to modify…
2
votes
1 answer

Is there a way to modify flask db migrate messages after execution?

I accidentally forgot to put a message while executing flask db migrate. I want to know whether there is any way to add the message right now. It's not pleasant nor helpful to see "empty message". Here is what my environment looks like, hope the…
Kutay Eroglu
  • 73
  • 1
  • 5
2
votes
0 answers

How to create a mssql VIEW model using flask-migrate?

Mssql+pyodbc connection. Imports and db from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, Table, text, Text, Unicode, MetaData from sqlalchemy.orm import relationship from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() I…
melvudin
  • 87
  • 7
2
votes
1 answer

Trying to change auto increment start value in my tables with Flask SqlAlchemy event.listen.But I am encountering table doesn't exist

models.py #imports class User(db.Model): __tablename__ = 'userstore' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True) password = db.Column(db.String(128)) role =…
2
votes
2 answers

How to delete flask migration folder and table

I want to fully delete the database and all the tables I have created. I tried everything. table_instance.table.drop(engine) I tried creating another project and reinstalling flask-migrate I still got No such revision '39408d6b248d' error and no…
kreki
  • 51
  • 2
  • 4
2
votes
1 answer

Flask-migrate No changes in schema detected

I am trying to understand how flask and sqlalchemy works.Below is my app structure init.py contains import os from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from flask_login import…
2
votes
0 answers

Error after Altering (Dropping columns and Change many-to-many membership) the SQLite in FLASK migrate

I had a User and channel class in my model.py. They had many-to-many relationships. I decided to remove the many-to-many relationships between User and channel and add the many-to-many relationship between Usertemp class and channel class. After…
math
  • 341
  • 4
  • 14
2
votes
1 answer

flask_migrate KeyError: 'migrate'

I'm currently learning flask and I'm looking into database relationships, however I'm trying the following commands in cmd: set FLASK_APP=app4.py flask db init When I run that, I get the following come through: Traceback (most recent call last): …
Kryton
  • 95
  • 1
  • 5
2
votes
1 answer

TypeError: can only concatenate list (not "str") to list | Alembic Migration

I am trying to run a migration to add a foreign key constraint. This is when I try to add a artist_id to my RSVP model on a many to one relationship. Each RSVP can only have an artist, and an artist can have many rsvps. Here is my migration code def…
2
votes
0 answers

How to use flask-migrate to migrate multi database with different table

I'm using Flask-SQLAlchemy connect to multiple databases. class Car(db.Model): id = db.Column(db.Integer, primary_key=True) brand = db.Column(db.String(80), unique=True) class Dog(db.Model): __bind_key__ = 'database_2' id =…
2
votes
1 answer

How do I properly edit Alembic migration scripts in Flask-Migrate/Flask-SQLAlchemy to add or edit columns?

I have a little app I'm using to scrape data from online articles. Currently, I am trying to figure out how to edit the migration scripts from Flask-migrate so I don't have to delete all the migration data and the SQlite database then re-scrape the…
2
votes
1 answer

Alembic recreates foreign keys every time I migrate causing duplicate foreign keys on my tables

I have a flask app using sql-alchemy and flask migrate to handle database changes. Every time I run a flask migrate to create a script for Alembic to update the database, the script contains commands to create foreign keys that already exist in my…
2
votes
1 answer

Will Flask-Migrate migrations work across different database engines?

I am writing a Flask application that uses Flask-SQLAlchemy and Flask-Migrate. Production has a PostgreSQL database, but for development, I was hoping to use SQLite instead of having to install full PostgreSQL on my development machine. I set up…
Dominick Pastore
  • 4,177
  • 2
  • 17
  • 29