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

Run alembic operations manually by code, using an sqlalchemy engine

I invested some time to understand Alemic, how I could run migrations manually without any setup. Due to some reasons we need that, we need to be able to execute operations manually without init, ini files or execution context.
Denny Weinberg
  • 2,492
  • 1
  • 21
  • 34
0
votes
1 answer

How to alter foreignkey with Alembic

I handle my PostgreSQL migrations with Alembic. This is how I create a table items: from alembic import op import sqlalchemy as sa def upgrade(): items_table = op.create_table( "items", sa.Column("id", UUID(as_uuid=True),…
lr_optim
  • 299
  • 1
  • 10
  • 30
0
votes
1 answer

alembic.command.check (version: 1.9.0) does not detect difference regarding names of constraints

I have been working on a project including SQLite, SQLAlchemy, and Alembic. My current task is to write a test to ensure that our migrations and the SQLAlchemy models are in sync. I happily found that there was introduced a new built-in command just…
Johnny
  • 337
  • 3
  • 15
0
votes
1 answer

Updating Azure Database for PostgreSQL flexible server using Alembic

I'm looking to amend some tables I have in a PostgreSQL instance on Azure, but I cannot work out how to perform the upgrades with Alembic. I have been following the tutorial here, which includes a Heroku deployment around the 12:01:00 mark. In that…
cookie1986
  • 865
  • 12
  • 27
0
votes
1 answer

How to run SQLAlchemy uploader coroutines inside sync alembic migrations?

I'm trying to populate my db with some data and to do so I'm making migrations in which I need to run async uploader that fetch files, parse it to SQLModel and insert to db with SQLAlchemy. I've initialized alembic as async and my env file is looks…
flintpnz
  • 41
  • 3
0
votes
1 answer

Alembic and mysql on newest distro

I want to enable realtime configuration on asterisk server. In the 2021 with a Slackware current, all works fine, now with Slackware 15 and Debian 11 I fail. I have installed the correct packages, configured and tested mariadb server, but when I try…
elbarna
  • 597
  • 1
  • 10
  • 26
0
votes
1 answer

flask db upgrade not working inside of docker container

Generally do not post here, so forgive me if anything is not up to code, but I have built a micro-service to run database migrations using flask-migrate/alembic. This has seemed like a very good option for the group I am working with. Up until…
0
votes
0 answers

Postgres index only top level keys in JSONB

I'm trying to figure out how to create an index on the KEY (UUID) in the following JSONB structure using alembic. I only really want to index the key as there are many fields.. I'm not sure how this is supposed to work as the field does not have a…
jack west
  • 569
  • 1
  • 4
  • 14
0
votes
0 answers

Flask-Migrate is just detecting the unique constraints not the whole model

When I try to use flask-migrate with my model and a Postgres database, it does not work. Even if the database is created at startup. Every time migrate only detects the following: INFO [alembic.autogenerate.compare] Detected added unique constraint…
0
votes
1 answer

flask-migrate / alembic: How to add a postgresql identity column to an existing table?

I’m trying to create a migration to add a new identity column to an existing table. The table should eventually become the new primary key of that table. class Action(db.Model): id = db.Column(db.Integer(), db.Identity(), primary_key=True) #…
zwirbeltier
  • 867
  • 9
  • 27
0
votes
0 answers

Why Alembic bulk_insert don't add data to DB?

In first migration I create table: from alembic import op import sqlalchemy as sa revision = 'ab45c3e5334d' down_revision = None branch_labels = None depends_on = None def upgrade() -> None: op.create_table('parts', sa.Column('id',…
Kirill
  • 1
0
votes
0 answers

Alembic Creating table with many-to-many relations

I'm writing my second FastAPI project, which is more complicated then the first one. It has many-to-many relations. I created proxy table for this relations. But then when I thought about the main table I stopped. I have many-to-many…
0
votes
1 answer

Is it possible to deactivate the autogenerated Drop?

I'm testing Alembic for a python project. The autogeneration is really nice, but dropping is not really helpful if you need to work on customer databases with many different versions for example. Activate or deactivate Dropping for different…
selinski
  • 13
  • 4
0
votes
0 answers

push data to database during migration

I am using alembic to create migrations. I want to bring data into a table during the first migration. There is a roles table in which you need to enter the data "loader" and "janitor". I do not know how to do that. I would be glad for any help!
0
votes
1 answer

error starting container in Kubernetes but not with docker-compose

My container runs fine using docker-compose. But once I apply my deployment on Kubernetes it fails every time on the same error. No matter what I try. I'm stuck and would love some input/help. I don't know how to debug this. A bit new at Kubernetes.…
kanadianDri3
  • 349
  • 2
  • 14