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

Python Flask Migrate is not ignoring existing tables in database outside my models

Following this link: https://alembic.sqlalchemy.org/en/latest/cookbook.html#don-t-generate-any-drop-table-directives-with-autogenerate I wanted flask db migrate to ignore existing tables outside of the context of my application, i thought all i…
BLang
  • 930
  • 3
  • 16
  • 35
0
votes
1 answer

Get compiled SQL of `create_all`

I'd like to speed my integration tests a bit and execute raw SQL code equivalent to create_all() My idea is to run create_all (in order to get it SQL equivalent) just once when the test session starts and use SQL code between the tests to migrate…
maslak
  • 1,115
  • 3
  • 8
  • 22
0
votes
1 answer

Alembic: Would updating a previous revision be beneficial?

I'm new to Alembic, so my apologies if I'm missing something, but I'm struggling to understand some methodology of my predecessor. My predecessor (at my company) has a series of revision files inside of the versions/ directory. If a change to the…
Regular User
  • 682
  • 7
  • 16
0
votes
1 answer

SqlAlchemy auto increment composite key for every new combination

I have a scenario to iterate up session_number column for related user_name. If a user created a session before I'll iterate up the last session_number but if a user created session for the first time session_number should start from 1. I tried to…
0
votes
1 answer

How to apply database first approach in Alembic?

I am new to Python ORM world. I wanted to generate model (code) from the existing database in Alembic or SQLAlchemy. I could find any docs about that. Just simply having already created database, I would like Alembic to generate me classes for that…
0
votes
1 answer

SQLAlchemy There are no primary or candidate keys that match the referencing column list in the foreign key

I have a model that was updated Before Users class Users(db.Model): username = db.Column(db.String(64), index=True, unique=True) user_created_timestamp = db.Column(db.DateTime) email = db.Column(db.String(120), index=True, unique=True) …
Sean Payne
  • 1,625
  • 1
  • 8
  • 20
0
votes
1 answer

Use uppercase letters adding new enum value in postgresql

I have an enum datasetId, to which I'd like to add another value. However, this doesn't work: ALTER TYPE datasetId ADD VALUE 'SOME_VALUE' and fails with sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedObject) type "datasetid" does not…
KarloSpacapan
  • 173
  • 2
  • 16
0
votes
1 answer

Can't rollback a particular Alembic migration by revision ID

I am trying to do schema migration in PostgreSQL via Alembic. Following this question Undo last alembic migration I have 2 migrations with: revision = '0eb4bd9decb0',down_revision = None --and revision = 'bf34bf428845' ,down_revision =…
Anurag Dabas
  • 23,866
  • 9
  • 21
  • 41
0
votes
1 answer

How to alter and merge columns with SQLAlchemy?

I am confused as to how to drop entire columns on a Flask server using SQLAlchemy. I changed a variable name in one of my models, and after running $ flask db migrate and $ flask db upgrade the associated table now has two columns: one with the old…
Brian Barry
  • 439
  • 2
  • 17
0
votes
0 answers

Maya 2020 How to connect joints to an animated alembic mesh

I'm trying to create joints on top of an animated Alembic mesh in order to use them later as a skin deformer.The current issue is that the joints are following the geometry. Do I need to create a proper character rig for that? Is there a simple way…
hervus
  • 1
  • 1
0
votes
0 answers

How can multiple engineers work on same DB with alembic?

We have a few engineers all working on the same database. When one runs alembic revision -m 'name' We get FAILED: Multiple heads are present; please specify the head revision on which the new revision should be based, or perform a merge. Not asking…
oooiiiii
  • 302
  • 2
  • 11
0
votes
0 answers

flask-migrate stuck on downgrade with table containing Enum field

I have defined the following models using sqlalchemy and my database backend is mysql. from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class Vehicle(db.Model): id = db.Column(db.Integer, primary_key=True) name =…
Mohammad hp
  • 446
  • 4
  • 16
0
votes
2 answers

alembic.util.exc.CommandError: Can't locate revision identified by 'f1942fde9843'

This happens when I do flask db migrate on my production PostgreSQL database. Locally, migrate works fine (also PostgreSQL). I'm not sure what's wrong. Some info: f1942fde9843 is not in my migrations/versions. I'm not sure why it's looking for that.…
maj
  • 79
  • 1
  • 9
0
votes
1 answer

How to run revisions with alembic?

I noticed that one of my columns had the wrong name so I changed it. Then I ran alembic upgrade head in the terminal in PyCharm and that didn't work so I dropped that table and another table that I had to drop so I could drop the table I made…
0
votes
1 answer

Flask-migrate change db before upgrade

I have a multi-tenancy structure set up where each client has a schema set up for them. The structure mirrors the "parent" schema, so any migration that happens needs to happen for each schema identically. I am using Flask-Script with Flask-Migrate…