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
0 answers

NoneType has no attribute 'schema' in alembic migration

I'm trying to generate some data in a migration to put in a table with quite a few columns. The migration in itself is part of several migration scripts, with the first one generating the table: #abcd123_initial_migration.py def upgrade(): …
enrm
  • 645
  • 1
  • 8
  • 22
0
votes
0 answers

SQL Alchemy relationship issue

I have the schema definition for postgres: from sqlalchemy.orm import declarative_base from services.db import DB from sqlalchemy import Column, String, text, DateTime, ForeignKey from sqlalchemy.orm import relationship import uuid Base =…
Rode093
  • 396
  • 2
  • 11
0
votes
1 answer

Alembic autogenerate from current database?

I have a database with a few tables in schema_a and views of these tables in schema_b, and want to use alembic revision --autogenerate to run have alembic detect the views i've created. When I run alembic revision --autogenerate either using…
enrm
  • 645
  • 1
  • 8
  • 22
0
votes
1 answer

Alembic autogenerate doesn't see changes

About stack: PostgreSQL with schemas Sqlalchemy == 2.0.15 Alembic == 1.11.1 I'm new to alembic instrument and during my development find out such problem: when I'm writing alembic revision --autogenerate -m ".." it generates me basic ddl with all…
0
votes
0 answers

How to make cross-platform makefile: read variable in Windows / Linux

The code below (in Makefile) works fine for linux, but I want to make universal makefile for linux and windows. migrations: @read -p "Enter migration message: " message; \ alembic revision --autogenerate --message "$$message" How can I do…
0
votes
1 answer

Alembic Error : No 'script_location' key found in configuration

alembic.ini file: [alembic] #path to migration scripts script_location = migrations Script I am running: alembic -n dev revision --autogenerate -m "alembic_migration_file" My project directory: |-migrations |--versions |----dev …
codechef
  • 1
  • 1
0
votes
1 answer

Is there a way to set `LOCK=NONE` when doing a ALTER TABLE via an alembic migration?

I would like to enforce that my migration doesn't lock a table. In plain SQL I would use ALTER ONLINE TABLE ... or ALTER TABLE x ADD COLUMN (...), LOCK=NONE. I can't find a way to replicate this with alembic using op.add_column.
Tewfik
  • 176
  • 2
  • 15
0
votes
0 answers

ValueError: invalid literal for int() with base 10: 'postgres'

I am a beginner in working with databases, but I am working on myself). I use Makos, PayCharm, Python, Alembic, Postgre. I have already done all the preparations, namely, created and checked the operation of the virtual environment, created all the…
0
votes
0 answers

Unable to find object name in outline bar

I have been working on animating on animating a peacock. The error which is coming up while exporting alembic file format is as follows- I have named two objects as 'joint One', however when I go to the outline bar, I am unable to find either…
Tulika
  • 1
  • 1
0
votes
1 answer

loose keys after alter table set schema

ran into a problem on PostgreSQL 12.5 ALTER TABLE old_shcema.my_table SET new_schema first - everything is OK, everything is transferred except triggers, but if you try back ALTER TABLE new_schema.my_table SET old_schema then keys, foreign keys…
Masta
  • 81
  • 6
0
votes
1 answer

flask db upgrade do not update to the latest version

I have Flask application with Flask-Migrate==2.2.1. And I have issue with running flask db upgrade command. Imagine that I have ten migrations (1-10) Locally it works as should after running flask db upgrade it set head to the newest migration (10…
M Kravets
  • 51
  • 5
0
votes
0 answers

Alembic use created column directly in query

I create a new column in a migration and want to directly use it in a query to add records but I get an error. Migration: def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table('wallets', …
Dirk
  • 3,095
  • 4
  • 19
  • 37
0
votes
0 answers

Alembic unable to resolve diff for custom schema

I have a table definition inheriting from sqlalchemy's DeclarativeBase: from sqlalchemy.orm import DeclarativeBase class Base(DeclarativeBase): pass class MyTable(Base): __tablename__ = "MyTable" __table_args__ = {"schema":…
Stan Reduta
  • 3,292
  • 5
  • 31
  • 55
0
votes
0 answers

in SQLAlchemy in many-to-many relations records in from link table are not deleted when deleting the parent record

I have the following model schema having 2 types of relationships: Student -> Grade (one-to-many) Student <- StudentClassLink -> Class (many-to-many) When deleting Student records, records from the Grade table are removed as well (one-to-many…
Pall Arpad
  • 1,625
  • 16
  • 20
0
votes
1 answer

How can I run an alembic schema update from a container on ecs fargate?

I have a backend service docker container which I intend to use to run alembic and update the data model in my database (an aurora serverless v1 running postgres). I have built the container and uploaded it to the ECR. The container's dockerfile…
Boris
  • 716
  • 1
  • 4
  • 25