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 to write portable Boolean columns for Alembic

I'm working on a Flask app using Flask-Migrate (and therefore Alembic) to manage changes to the DB. I've run into an issue early on where changing some not-nullable boolean columns has triggered an error in the underlying DB. I am removing one…
mpounsett
  • 1,174
  • 1
  • 10
  • 30
1
vote
0 answers

Set PostgreSQL type during Alembic’s create_table

I have a model with a PasswordType column (from SQLAlchemy-Utils): class User(Base): __tablename__ = 'users' id = sa.Column(sa.Integer(), primary_key=True) username = sa.Column(sa.String(length=80), nullable=False, unique=True) …
GergelyPolonkai
  • 6,230
  • 6
  • 35
  • 69
1
vote
1 answer

How to update tables schemes in Python, using only Python (No CLI)

I am working with SQL Alchemy, and wish to update the tables schemes automatically, without using CLI (The structure of my code prevent it) I don't need to store migrations files either. I have been looking for Alembic, which seems to be the best…
Hermios
  • 622
  • 1
  • 5
  • 20
1
vote
0 answers

run database migration through a k8s job

I want to run database migration via a job in k8s. The database is located in a mariadb pod in the same cluster, installed through bitnami/mariadb helm chart. So I think the mariadb can be seen/exposed as a service. How can I let migration pod…
Ya He
  • 43
  • 1
  • 3
1
vote
1 answer

How to backfill an incrementing id using alembic in postgres

I have a flask app that is backed by a postgres database using flask-sqlalechmy. I've been using miguel grinberg's flask migrate to handle migrations, although I've come to realize that since it is a wrapper on top of alembic, I'm best served by…
Seanyboy Lee
  • 165
  • 1
  • 12
1
vote
2 answers

SQLAlchemy Alembic: Issue with URL for SQLServer

I was trying to create a database migration script with Alembic for my SQLServer database and having issues with the connection string. This is what I have now: sqlalchemy.url = "mssql+pyodbc://db_server/database?trusted_connection=yes&driver=ODBC…
1
vote
1 answer

Alembic autogenerate not detecting current state

Problem I'm using Alembic autogenerate to migrate some model changes. I run alembic revision/upgrade once and it properly creates my table and adds an alembic_version table to my database. When I go to run the revision/upgrade command again, it…
Spothedog1
  • 349
  • 2
  • 3
  • 10
1
vote
0 answers

SQLalchemy cant find my tables, but alembic finds them just fine

I'm starting a project with SQLAlchemy and Alembic. I'm using SQLite for testing purposes. When I execute alembic revision --autogenerate -m "..." it correctly generates the migrations and when I execute alembic upgrade head it creates the table and…
Justcurious
  • 1,952
  • 4
  • 11
  • 17
1
vote
1 answer

Cross reference while defining FK and children relationships SQLAlchemy

Class Bed id Class Guest id bed_assignments = relationship( primaryjoin=( "and_(Guest.id" "==foreign(BedAssignment.guest_id)," "BedAssignment.bed_status=='occupied')" …
Azuz
  • 31
  • 6
1
vote
1 answer

SQLAlchemy not updating changes causing issues

So I've made some changes to my schema on a Flask Server, using SQLite and SQLAlchemy. The database is generally functional and I'm able to add some of the models, as well as update and query all models without issues. I've changed the id in two of…
Maxime Franchot
  • 1,015
  • 1
  • 10
  • 24
1
vote
0 answers

Alembic migration hangs after creating db session

I'm using this approach to talk to an external database in my alembic migration. I can run SELECT statements and read data from the other database, but the alembic migration always ends up hanging after running my statements. I've noticed that…
jgozal
  • 1,480
  • 6
  • 22
  • 43
1
vote
1 answer

alembic upgrade as heroku release

I'm pulling my hair out, any help would be appreciated. I'm attempting to run an alembic upgrade on deployment of my new app. I've been searching stack overflow for 3 hours now and cannot find anything that works. Every thing I do has the same…
bravosierra99
  • 1,331
  • 11
  • 23
1
vote
0 answers

Including username in Alembic migration file header

as the title suggests I wish to include the name of the developer generating the migration file within its header when using the auto generation tool. The format of the migration header is set in the script.py.mako file and can include different…
NxtGenLvl
  • 11
  • 1
1
vote
2 answers

Single Schema Postgres Alembic Autogenerate Migration

I have a Postgres server which we have one database in. This one database is our data warehouse. We have a schema per software application in this database. I'm working on a new project which I'm using sqlalchemy's alembic to create the schema…
Alex Luis Arias
  • 1,313
  • 1
  • 14
  • 27
1
vote
0 answers

Alembic migration doesn't generate UUID correctly

In fact surely it does, but I'm certainly doing something wrong. I've got a database where I create a FK on a table and in a future migration, it's dropped. So the create statement of the table is: CREATE TABLE this_table ( pk INTEGER NOT NULL, …
PirklW
  • 484
  • 2
  • 16