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
1 answer

Tables are detected when running migration, but aren't created in database

I ran a migration to create the SQLite tables for a cookiecutter Flask app. Although the database file exists and I can open it, I cannot see the tables. When I try to create a user I get a "no such table" error. Why doesn't the table exist even…
user1592380
  • 34,265
  • 92
  • 284
  • 515
3
votes
1 answer

flask migrate seemed to delete all my database data

Here is my migration file : from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_script import Manager from flask_migrate import Migrate, MigrateCommand import models app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI']…
user442920
  • 857
  • 4
  • 21
  • 49
3
votes
1 answer

Flask Migrate: Alembic converting choices into 255

I'm using sqlalchemy_utils to add a "choices" field to my database. And after I ran my migrate using Flask Migrate, it converts all my choices into 255, below is a simplified example: # models.py from sqlalchemy_utils.types.choice import…
benjaminz
  • 3,118
  • 3
  • 35
  • 47
3
votes
2 answers

How can I migrate flask-sqlalchemy multiple databases?

I know multiple databases work on flask-sqlalchemy with __bind_key__. But I don't know how to migrate those databases on alembic(flask-migrate). Here's env.py: from flask import current_app config.set_main_option('sqlalchemy.url',…
Jony cruse
  • 815
  • 1
  • 13
  • 23
3
votes
3 answers

setting up Flask db migrations with Elastic Beanstalk

I have set up a site built on Flask sing eb (the Terminal client for Elastic Beanstalk v3.1). When deploying a new version of my site I get "Update environment operation is complete, but with errors. For more information, see troubleshooting…
3
votes
1 answer

change database migrations from sqlalchemy-migrate to Flask-Migrate

I have an web app base on miguel flask tutorial So I use sqlalchemy-migrate for database and Now I should Use Alembic in migration How can I do the configuration? is there any way that I can change from sqlalchemy-migrate to Flask-Migrate?(coz my…
Linda
  • 551
  • 2
  • 7
  • 16
3
votes
2 answers

Flask-migrate on openshift

I am using flask. I installed Flask-migrate and have been using it to migrate my postgresql db. It works fine on my local box. However, when I run it on openshift I get an error "File "/opt/rh/python27/root/usr/lib64/python2.7/ConfigParser.py",…
user3330833
  • 2,179
  • 2
  • 12
  • 9
2
votes
1 answer

How can I extend every unique key constraint of all models with a common key across using Flask-SQLAlchemy and Flask-Migrate in Python?

Want to extend every unique key constraint of all models with a common key across. Have tried multiple things but doesn't seem to working when I do flask db init; flask db migrate -m "init"; flask db upgrade; But it works and…
2
votes
1 answer

Railway.app: Running command (Flask-Migrate) in Deployed Service Environment

I am in the process of migrating a Python flask web app from Heroku to Railway. The app uses a set of Flask CLI commands to initialize and update a Postgres database schema. In the development environment, for example, I would run "flask db migrate"…
m-a-draco
  • 35
  • 5
2
votes
3 answers

flask db upgrade returns "Table already exist" Error

So I created a simple table with MySQLAlchemy, and everything works pretty fine. My code. from app import db from werkzeug.security import generate_password_hash, check_password_hash class register_users(db.Model): __tablename__='new_user' …
2
votes
1 answer

MySQL Unknown column in CHECK

I have a MySQL database And I want to add a column: MariaDB [(none)]> use myDatabase; Database changed MariaDB [myDatabase]> ALTER TABLE material add new_column FLOAT; But I get the following error: ERROR 1054 (42S22): Unknown column…
snin
  • 43
  • 5
2
votes
1 answer

Can flask_migrate be run with sqlAlchemy create_engine in a database init file?

If I have an init.py file which looks as such: from sqlalchemy import create_engine import os from sqlalchemy.orm import sessionmaker, scoped_session from testserver.database.models.Base import Base from sqlalchemy.ext.declarative import…
Ben_Sven_Ten
  • 529
  • 3
  • 21
2
votes
0 answers

Alembic/Migrate does not recognize a materialized view

I have created a postgres materialized view following Jeff Windman's methodology from here: How to make SQLAlchemy custom DDL be emitted after object inserted? and here: http://www.jeffwidman.com/blog/847/ The view factory and the model were adapted…
grommit
  • 169
  • 2
  • 14
2
votes
0 answers

Flask-Migrate, SQLITE3: Trying to change column so that 'default=False'. ERROR = SQL: ALTER TABLE user ALTER COLUMN confirmed SET NOT NULL

Using Flask-Migrate and SQLite3, I am trying to alter column 'confirmed' in table 'user' so that becomes NOT NULLABLE and has a default value of false. I have updated the existing rows so that confirmed = false for all of the entries. Though when I…
2
votes
0 answers

flask: error: unrecognized arguments: db migrate

I have a flask app and have managed to run db init on it. Now I'd like to add a column to the db and thus migrate it. When I type flask db migrate in my terminal (from within my virtualenv) I get an error: usage: flask [-h] [--port PORT] flask:…
Muriel
  • 449
  • 4
  • 20