Questions tagged [alembic]

Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python.

Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python.

Some of the important operations that can be performed with alembic are

  • Upgrade(Perform Database migrations, Example: create/alter/modify)
  • Downgrade(Its the reverse operation of upgrade to undo the upgrade changes)
  • Current(Show the current revision and state of migration in the database)
  • Init(Initialize a new scripts directory)
  • Revision(Create a new revision file)

Related tags

References

854 questions
0
votes
1 answer

Migrate/Copy a database using automap_base and alembic

I have a database x with some amount of data filled in every tables. I want to create a copy of that database (with same schema and exact data). First I create a Declaritive Base class of x using automap_base. from sqlalchemy.ext.automap import…
Anum Sheraz
  • 2,383
  • 1
  • 29
  • 54
0
votes
0 answers

alembic upgrade head with no output

I'm having troubles trying to upgrade the database of my Flask API. I want to add a new column to table "persons". I have this structure : -- app -- alembic -- env.py -- README -- versions -- c12d697e5535_add_a_column.py --…
Souad
  • 4,856
  • 15
  • 80
  • 140
0
votes
0 answers

Flask-Alembic error sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) type does not exist

I'm trying to automate upgrade of database for project written in Flask. I use alembic for Flask. The problem is when I use several enums it always run the error on the second enum, I don't understand why and how to fix it. File enums.py: from enum…
mimic
  • 4,897
  • 7
  • 54
  • 93
0
votes
1 answer

SqlAlchemy + Alembic - how to fix schema discrepency

I just pushed up my Flask app to my staging environment and I noticed that I now have a discrepancy between the two Postgres databases. My staging database has an id column in the instance_tags table while my local database does not. Three…
hugo
  • 1,175
  • 1
  • 11
  • 25
0
votes
0 answers

How to ignore some models to migrate?

i have question. I have models called Visitor, that i don't want to Migrate when i run flask db migrate, because i already have the table in database. my question is how to avoid that models to become a table ? here my visitor.py class…
0
votes
1 answer

Delete large number of rows in Postgres/SQLAlchemy/Alembic

I have a table that is about 150 GB with about 1 billion rows in Postgres. We have a Flask app that INSERTs to this table using SQLAlchemy and we handle database migrations via Alembic. This has been working great for us but we really should just…
rith87
  • 413
  • 4
  • 10
0
votes
1 answer

How does one resolve a "Table already exists" error in Flask?

I'm having an issue I don't really know how to approach with Python Flask. For reference, I'm using SQL-Alchemy and flask-migrate for the database. That said. I'm getting the following error: "table guilds model already exists" when I run the…
Wavegunner232
  • 61
  • 1
  • 2
  • 9
0
votes
1 answer

Automatic migrations with reflected tables in Alembic + SQLAlchemy

I'm setting up alembic for our project, which is already really big, and has a lot of tables. The thing is that our project's DB has been managed via SQL for a long time, and our Alchemy models are almost all reflected like so (I obscured the name,…
Lacrymology
  • 2,269
  • 2
  • 20
  • 28
0
votes
1 answer

Error in migrating and upgrading in Flask with sqlalchemy_utils ChoiceType

I am using flask-migrate to adjust my database changes. $python manage.py db init $python manage.py db migrate These work fine but when i use $python manage.py db upgrade This error happens TypeError:
handsomer223
  • 885
  • 4
  • 12
  • 16
0
votes
2 answers

flask-migrate alembic.util.exc.CommandError python

I am using flask-migrate to update the changes in my database. I ran this command. and then this command $python manage.py db init $python manage.py db migrate I get the error below alembic.util.exc.CommandError: Can't locate revision…
handsomer223
  • 885
  • 4
  • 12
  • 16
0
votes
2 answers

Alembic error on Heroku: Can't find Python file migrations/env.py

Trying to deploy a Flask app on Heroku, used to work perfectly with other apps, but now when I try to upgrade the db with: >:heroku run python manage.py db upgrade I get the following error: Traceback (most recent call last): File "manage.py",…
Libra
  • 369
  • 4
  • 15
0
votes
0 answers

How to create new type in sqllachemy

Hi I want to create new field in sqlalchemy similar to FileField from Django from sqlalchemy import String class FileField(String): """A mixin that adds field for storing files""" def __init__(self, length=None, filename='test'): …
kpazik
  • 175
  • 2
  • 11
0
votes
1 answer

Alembic sqlalchemy migration assistant not tracking existing tables

I am trying to set up alembic to autogenerate migrations. Currently when I run this line of code: alembic revision --autogenerate -m 'add column' alembic checks for changes in the spatial_ref_sys, which I have told it to ignore, and then creates a…
0
votes
1 answer

Impossible to DROP TABLE / postgres / docker

I'm currently working on a Flask server, and a postgresql database running in a docker. I wanted to delete a table with a migration using alembic, but when I wanted to apply it it was just frozen and I had a process DROP TABLE waiting that was…
gvandeve
  • 11
  • 1
  • 3
0
votes
1 answer

Type convert from date to datetime in MySQL

If I type convert from date to datetime in order to store time of day, what will be the default value for the time of day? I want to migrate the data which is just dates. There are pairs from "value_to" and "value_from" in the data. These values…
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424