alembic

Alembic – how to create hypertable

Alembic – how to create hypertable Question: How to generate hypertable using Alembic? Some custom call must be added I suppose, but where? I tried event.listen but Alembic does not register it. Asked By: romanzdk || Source Answers: You can create hypertables in Alembic by adding manual, custom, migration actions. You cannot generate it automatically, …

Total answers: 2

Why Can't I Add a Column using Alembic Because it isn't in the Table?

Why Can't I Add a Column using Alembic Because it isn't in the Table? Question: So I’m trying to use alembic to add a column to my table. Here’s my class defining the table with the new line in bold: class Account(db.Model): id = db.Column(db.Integer, index=True, primary_key=True) account_number = db.Column(db.String(10), index=True) primary_member_fk = db.Column(db.Integer) first_deposit …

Total answers: 1

Distribute Alembic migration scripts in application package

Distribute Alembic migration scripts in application package Question: I have an application that uses SQLAlchemy and Alembic for migrations. The repository looks like this: my-app/ my_app/ … # Source code migrations/ versions/ … # Migration scripts env.py alembic.ini MANIFEST.in README.rst setup.py When in the repo, I can call alembic commands (alembic revision, alembic upgrade). I want …

Total answers: 2

Create CompositeArray of CompositeType without using sqlalchemy_utils

Create CompositeArray of CompositeType without using sqlalchemy_utils Question: Within my FastAPI, SQLAlchemy, Alembic project, I was using postgresql engine, and now I’m trying to migrate to async with postgresql+asyncpg. The issue here is that one of my DB schemas has this structure: class MyTable(…): __tablename__ = ‘my_table’ name = Column(String(255), nullable=False, unique=True) tridimensional = Column(CompositeArray( …

Total answers: 2

Flask migrate error – foreign key associated with column could not find table with which to generate a foreign key to target column

Flask migrate error – foreign key associated with column could not find table with which to generate a foreign key to target column Question: I have two models as following in different files. When I run flask db migrate I get this error. raise exc.NoReferencedTableError( sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column ‘datasets.user_id’ could not find …

Total answers: 2

FASTAPI run in conjunction with Alembic, but autogenerate does not detect the models

FASTAPI run in conjunction with Alembic, but autogenerate does not detect the models Question: I am relatively new to FASTAPI but decided to setup a project with Postgres and Alembic. I managed to get the migrations create new versions everytime i use an automigrate, but for some reason I do not get any updates from …

Total answers: 3

alembic autogenerates creates empty migration but generates table

alembic autogenerates creates empty migration but generates table Question: I followed the documentation from Alembic to auto-generate migrations. My project structure looks like this: alembic/ versions/ env.py README script.py.mako data/ __init__.py db.py models.py alembic.ini app.db I made changes to env.py by exactly following the document: from logging.config import fileConfig from sqlalchemy import engine_from_config from sqlalchemy …

Total answers: 2

Alembic doesn't recognize False default value

Alembic doesn't recognize False default value Question: While maintaining a SQLAlchemy data model and utilizing alembic for version control, the following code change I made resulted in an empty revision: some_column = Column(Boolean, nullable=False, default=False) While previously it was: some_column = Column(Boolean, nullable=False) So adding a default value produces no changes in alembic, i.e. generates …

Total answers: 2

How do I check if Alembic migrations need to be generated?

How do I check if Alembic migrations need to be generated? Question: I’m trying to improve CI pipeline to prevent situations where SQLAlchemy models are added or changed, but no Alembic migration is written or generated by the commit author from hitting the production branch. alembic –help doesn’t seem to provide any helpful commands for …

Total answers: 2