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

Alembic migration version not recognizing relationship columns, only the Foreign Key

I am trying to deploy a simple sqlite model.py file. Alembic, in general, is working, because it recognizes all my changes in the model. The problem is that I have two columns not recognized, and they're just the ones which the relationship should…
caio_alBR
  • 27
  • 5
0
votes
0 answers

Different Postgres schemes with different models in Python alembic

I am new to using SQLAlchemy and Alembic and I’m trying to work with different models and schemas in a Postgres database. These schemas represent different system domains and the idea is to unify database models and migrations into a single project.…
0
votes
0 answers

How to properly perform DLRN database migrations after version upgrade?

After upgrading DLRN pip package (0.25.0 > 0.26.1), the existing database schema is now deprecated and builds no longer succeed. According to the official documentation regarding upgrades and migrations, DLRN seems to be bundled with support for…
iZ0x0x7
  • 43
  • 3
0
votes
0 answers

Alembic / SQLAlchemy / Flask - Migration want to delete all existing tables

I have an existing database with tables created by SQLAlchemy. I want to add Alembic to help me with migration. But when I execute flask db migrate, Alembic want to remove all existing tables: INFO [alembic.autogenerate.compare] Detected removed…
Tomy137
  • 91
  • 9
0
votes
1 answer

db migration problem using Flask-Migrate and PostGIS: Cannot drop table spatial_ref_sys because extension postgis requires it

I'm currently working on a python backend using Flask, SQLAlchemy and flask-migrate/alembic. When I run flask db upgrade head (after performing init and migrate), I get the following error for the 'spatial_ref_sys' table of…
Scopuli
  • 1
  • 2
0
votes
0 answers

Python Alembic - create column that is pipe delimited concatenation of items in list in json

I'm using alembic to create a new column in a mysql table. The table has a column source_list that is json {"sources": ["source1" "source2"]} I want to create a new column, sources, that is a pipe-delimited concatenation of the list…
sam
  • 653
  • 9
  • 21
0
votes
1 answer

Alembic migration No schema selected to create in

I am trying to run my migration in which there are also enums in few tables. Something like below op.create_table('test_table', sa.Column('name', sa.String(length=250), nullable=False), sa.Column('status', sa.Enum('CREATED', 'COMPLETED',…
Prakash
  • 396
  • 1
  • 6
  • 23
0
votes
1 answer

SQLAlchemy + Flask managing several databases and migration

I need to write an application using SQLAlchemy + Flask AppBuilder. Currently I use 2 databases and it works well(with SQLALCHEMY_BINDS in config, separate metadata and bind_key parameter). When I am trying to add tables with the same names to the…
0
votes
0 answers

Timestamp should not change on alembic upgrade

I just ran an alembic upgrade on my postgresql db. The diff between "before" and "after" revealed that all tables were rewritten despite the fact that only some tables were modified. The change occured only in the datetime column like so: < 202 …
Robert
  • 652
  • 2
  • 11
  • 23
0
votes
0 answers

Dynamically set up the version_locations in env.py for alembic migrations

I am using alembic to manage my database changes. Other people may also add changes to this database. Everything is set up correctly and this is currebtly working fine. However, because we are many to modify the db and therefore create new .py for…
Bloux
  • 3
  • 3
0
votes
0 answers

Alembic revision autorgenerate missing comment on create_geospatial_table

I am working with alembic==1.11.1, SQLAlchemy==2.0.19 and GeoAlchemy2==0.14.0. I have a few tables defined, some of which have Geometry type imported from GeoAlchemy2. All of them have the same table arguments: __table_args__ = { 'schema':…
Rorepio
  • 332
  • 1
  • 4
  • 16
0
votes
0 answers

Pydantic BaseSettings cant find .env when running commands from different places

So, Im trying to setup Alembic with FastAPI and Im having a problem with Pydantic's BaseSettings, I get a validation error (variables not found) because it doesnt find the .env file (?) It can be solved by changing env_file = ".env" to env_file =…
Risker
  • 358
  • 3
  • 15
0
votes
0 answers

How to debug Alembic migrations inside VS Code?

Say I have a migration script like this one: # revision identifiers, used by Alembic. revision = 'b5c9e0aac59b' down_revision = '4658d3e26bae' branch_labels = None depends_on = None def upgrade(): print("hello world!") And I want to place a…
Be Chiller Too
  • 2,502
  • 2
  • 16
  • 42
0
votes
0 answers

Can I add a custom column to the 'transaction' table automatically generated by SQLAlchemy-Continuum for audit trail?

I've successfully performed a log of an UPDATE action of a PostgreSQL database using SQLAlchemy ORM. Firstly, using Alembic, I've migrated the automatically generated 'XXX_version' (where XXX is the name of the original table) and 'transaction'…
0
votes
0 answers

Alembic unable to build upon pre-existing data schema

Here is my current setup: An API running on fastAPI & AWS ECS A postgresql database hosted by Supabase; I'd like to use supabase for some of its on-the-shelf features such as user authentication Using sqlalchemy for ORMs and alembic for data…
Pjob
  • 1