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
1
vote
1 answer

how can I change the geometry name in abc file by python

I export the animation into alembic file in maya 2014. Then, I want to import it and connect to a render model by the Abcimport. But,the render model's shape is not same such as : the abc model's shape : aaaShapeDeformed the render model's shape…
1
vote
1 answer

Creating Double precision columns using SqlAlchemy from Alembic

I need to use a DOUBLE column in my MYSQL db. I've read the docs, which suggest I use a Float with precision of 64. This, however, doesn't seem to be working. I end up with a regular float column, and the required precision does not exist. I also…
domoarigato
  • 2,802
  • 4
  • 24
  • 41
1
vote
0 answers

What is causing this CircularDependencyError and how is it fixed?

When I try to migrate my database I get a CircularDependencyError. I found some information about this in the Core Exceptions docs and tried to add post_update=True, but it didn't solve the issue. I can see it's a problem of mutual relations…
HMPark
  • 85
  • 1
  • 6
1
vote
1 answer

Changing MySQL Column collation with Alembic upgrade() script

Would like to change a Column collation from utf8mb4_unicode_ci to utf8mb4_bin Its updated SqlAlchemy model is col_name = Column(VARCHAR(10, collation='utf8mb4_bin'), nullable=True) I have tried from alembic import op import sqlalchemy as…
ting12
  • 81
  • 10
1
vote
1 answer

how to handle exceptions in alembic migrations?

I have an alembic migration script and I want to add some exception handling but not sure what is the best practice. Basically, I have several issues to handle: A change was already made and not needed (e.g. if I try to add_column, and this column…
Ofir
  • 1,565
  • 3
  • 23
  • 41
1
vote
0 answers

Flask-Migrate: column addition / removal apparently undetected, tables recreated instead

I'm using Flask-Migrate in a Flask application with a Postgresql backend. The problem is that after making a change to my models, say a column addition or removal, in any revision or migration that I have tried I always get results along the lines…
1
vote
0 answers

Resize string column of Postres in Heroku with alembic

I want to change the size of a String column in my PostgreSQL database through alembic. My first attempt in my local DB was the more straightforward way and the one that seemed logic: Change the size of the db.Column field I wanted to resize and…
josebama
  • 848
  • 8
  • 11
1
vote
1 answer

alembic doesn't detect relationship table

I've defined some models with some association tables for m2m relationships: from itsdangerous import TimedJSONWebSignatureSerializer from passlib.hash import bcrypt from sqlalchemy.ext.declarative import declarative_base import app from app…
rxdazn
  • 1,380
  • 1
  • 14
  • 30
1
vote
1 answer

Reading BLOB (LargeBinary) from SQLite via Flask SQLAlchemy returns None

I am trying to read a BLOB (LargeBinary) object from SQLite using Flask-SQLAlchemy, and I'm getting this error: TypeError: must be string or read-only buffer, not None. My code is as follows: @app.route('/csv/', methods=['GET']) def…
Mark Richman
  • 28,948
  • 25
  • 99
  • 159
1
vote
1 answer

Alembic migration script for a MySQL View using DATE_FORMAT

We are attempting to generate a SQL Migration script using Alembic (offline mode). Part of the view in the migration uses the MySQL function DATE_FORMAT, as in the example below. When the migration scripts are created, the percent characters are…
1
vote
1 answer

Alembic detects changes but produces empty migration with --autogenerate

I'm trying to get alembic working auto-producing migrations with the --autogenerate flag. When I run alembic -n mydbname --autogenerate -m "my message" I get something like: INFO [alembic.migration] Context impl MySQLImpl. INFO [alembic.migration]…
Colleen
  • 23,899
  • 12
  • 45
  • 75
1
vote
1 answer

Detect changes to models.py using Alembic with Flask-SQLAlchemy in Flask Application

I'm trying to use Alembic with Flask-SQLAlchemy and Flask. Here is my application directory structure /myapp app.py /module1 __init__.py views.py /module2 __init__.py models.py alembic.ini …
Sandeep Raju Prabhakar
  • 18,652
  • 8
  • 35
  • 44
0
votes
0 answers

alembic to autogenerated computed columns , generated as always in postgres

I have a column as such in my model: class Mem(BaseMem,table=True): id: Optional[int] = Field(sa_column=Column(Integer,Identity(always=True,start=1,cycle=True),primary_key=True,nullable=False)) it_service_instance: Optional[str] =…
moth
  • 1,833
  • 12
  • 29
0
votes
0 answers

How to use alembic when applying to different databases based on environment variables?

I am trying to use alembic and I have different databases based on the environment and it decides which databases to use. For example stage and dev have different databases. When I use alembic migrations in this manner same scripts under the version…
0
votes
1 answer

Alembic autogeneration custom schemas

Im trying to create table with custom schema, created in Base class. Base class: @as_declarative() class Base: """Base class for all database entities""" @classmethod @declared_attr def __tablename__(cls) -> str: """Generate…