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

Access denied when Flask-migrate connects to MySQL server via SSH tunnel

TL;DR: When I try to use flask db migrate with a remote database, I get: MySQLdb._exceptions.OperationalError: (1045, "Access denied for user ''@'localhost' (using password: YES)"). But I'm certain that the username and password are correct, the…
Nick K9
  • 3,885
  • 1
  • 29
  • 62
1
vote
1 answer

Stored procedure with Alembic: MySQL Syntax Error

I am using Alembic to load a stored procedure into the MySQL database. Following the cookbook, I was able to create the required objects for creating and dropping the procedure. Now that I want to upgrade the version to actually load the procedure,…
A23149577
  • 2,045
  • 2
  • 40
  • 74
1
vote
1 answer

Alembic: is there a way to store head revision number in DB?

Is there any way to store current revision number in the db? I mean, when I generate migration and upgrade head, how I can insert this revision number in the db, and check the table for this revision number in next time, when I will do a migration.
MrOldSir
  • 616
  • 3
  • 9
  • 28
1
vote
1 answer

Flask Migrate keeps trying to create existing tables

I have an existing Flask app. I am trying to integrate schema version control on an existing Oracle db. When running: python manage.py db migrate Flask is trying to create tables that are already in the database. I tried running: python manage.py…
Lev
  • 999
  • 2
  • 10
  • 26
1
vote
1 answer

How can I revert a partially executed migration?

I recently executed flask db migrate and got an exception in between (details). The migration was only partially done. What I did The migration looked like this: def upgrade(): # ### commands auto generated by Alembic - please adjust! ### …
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
1
vote
0 answers

Problem in migrating multiple project tables into one database using logical separation with alembic migrations

I have two web services with different packages both using flask-sqlalchemy, postgres, alembic. I want to migrate both services in one database using logical separation(means define different schemes under one database),I am not able to migrate both…
1
vote
0 answers

Is there an ORM structure which allows me to have tables which result in Catalog.Schema.Table?

I am currently working on a project with a pre-existing database. The Server is a clustered server with multiple Catalogs (database), and in each Catalog there are multiple Schemas with Tables. The table name format for the traditional SQL query…
Dan
  • 13
  • 1
  • 5
1
vote
1 answer

Verify alembic migrations in pipeline build

I have setup a build pipeline on Azure to execute pytests and such. In addition, I'd also like to check if no migrations have been missed. Running the alembic command with --autogenerate will generate a new migration file in case it isn't there yet.…
wasp256
  • 5,943
  • 12
  • 72
  • 119
1
vote
0 answers

Does apache-airflow support Sybase as metadata db?

After setting sql_alchemy_conn to sybase connection string, initdb command is failing with below error. Is it because apache-airflow doesn't support Sybase as metadata db? airflow initdb ... ... {db.py:222} INFO - Creating tables Traceback (most…
ppp
  • 975
  • 7
  • 15
1
vote
0 answers

How do I fill a newly created column with UUID using flask-migrate?

I have added a new column to my SQLAlchemy model and generated the migration script with flask-migrate. I want to populate this new column with a random UUID for every row in my table. Is this possible in flask-migrate?
jminardi
  • 936
  • 1
  • 11
  • 23
1
vote
2 answers

Alembic Downgrade,Upgrade,Revision and Migrate are doing nothing

EDIT: This apparently is effecting trying to upgrade or create a new revision file as well. I've been trying to run a downgrade in Alembic, which I have gotten to work before, with no luck. My current revision ID never changes and I was wondering…
J. Finn
  • 129
  • 1
  • 11
1
vote
1 answer

Adding UniqueKey constraint to a sqlite3 table with Flask-Migration fails with IntrgrityError

So I using sqlite as my test database and have the following classes in my models.py class User(UserMixin, db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True, index=True) username = db.Column(db.String(40),…
Rohit
  • 3,659
  • 3
  • 35
  • 57
1
vote
0 answers

How to rollback all migrations if error occurs?

It seems there is a way to rollback all changes on error but the example script seems odd because the reference session, used in the script, is never defined or imported: from alembic import context import myapp import sys db_1 = myapp.db_1 db_2 =…
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
1
vote
1 answer

Alembic conditional based on database engine

Can alembic run slightly different migration code based on database type? For example, run ALTER TABLE object AUTO_INCREMENT = 6000; only on MySQL, but skip this for SQLite? Some background: We're using alembic to run migrations. On many dev…
Charles L.
  • 5,795
  • 10
  • 40
  • 60
1
vote
1 answer

Is there an way with flask-migrate/alembic to list migrations that have been applied to a DB?

I would like to list all migrations and the db status (whether a migration has been applied or not). I'm looking for an equivalent of rails rake db:migrate:status. example output from rake db:migrate:status: database: dev Status Migration ID …
Tewfik
  • 176
  • 2
  • 15