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

Alembic is not detecting difference between database and code

I delete the contents of the alembic_version table in my database, and I then delete the contents of the alembic/versions directory. I then run: PYTHONPATH=. alembic -c ./alembic.ini revision --autogenerate -m 'your message about the…
Duke Dougal
  • 24,359
  • 31
  • 91
  • 123
3
votes
2 answers

Alembic/Flask-Migrate not detecting after_create events

I have a simple Flask-SQLAlchemy model (with event listener to create trigger): from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class Confirm(db.Model): created = db.Column(db.DateTime, default=db.func.current_timestamp(),…
3
votes
1 answer

Tables are detected when running migration, but aren't created in database

I ran a migration to create the SQLite tables for a cookiecutter Flask app. Although the database file exists and I can open it, I cannot see the tables. When I try to create a user I get a "no such table" error. Why doesn't the table exist even…
user1592380
  • 34,265
  • 92
  • 284
  • 515
3
votes
0 answers

How to improve Alembic Migration merge performance?

I have been using Michael Bayer's (@zzzeek) Alembic Migrations library to handle my application postgres database needs for over a year and really like it. It's a great tool and has been a great asset. I have a team of several developers and we…
Corey Coogan
  • 1,569
  • 2
  • 17
  • 31
3
votes
1 answer

alembic "failed to create process." in Windows7

I already installed python2.7, pip, env and alembic successfully, I try to run command "alembic init elembic" in command prompt but it not success, it show the message "failed to create process.". Anyone why and how to solve it?
Ry Rith
  • 117
  • 1
  • 10
3
votes
1 answer

Flask Migrate: Alembic converting choices into 255

I'm using sqlalchemy_utils to add a "choices" field to my database. And after I ran my migrate using Flask Migrate, it converts all my choices into 255, below is a simplified example: # models.py from sqlalchemy_utils.types.choice import…
benjaminz
  • 3,118
  • 3
  • 35
  • 47
3
votes
1 answer

MySQL DB migration: change of string length

I'm using SQLAlchemy + alembic to manage my database. I had a string field which was 10 characters long and later on found out that it has to be 20. So I updated the model definition. class Foo(db.Model): __tablename__ = 'foos' id =…
lang2
  • 11,433
  • 18
  • 83
  • 133
3
votes
1 answer

Run alembic migrations one by one for multiple databases

In our project we have multiple databases and we use alembic for migration. I know that alembic is supposed to be used only for database structure migration, but we also use it for data migration as it's convenient to have all database migration…
Minras
  • 4,136
  • 4
  • 18
  • 18
3
votes
1 answer

Is there a python-alembic way to convert data between dropping and adding a column?

I have a sqlite3 database accessing it with SQLAlchemy in python3. I want to add a new and drop an old column with the database-migation tool alembic. Simple example: class Model(_Base): __tablename__ = 'Model' _oid = Column('oid', sa.Integer,…
buhtz
  • 10,774
  • 18
  • 76
  • 149
3
votes
0 answers

Issues in flask-restless due to sqlalchemy.db.Boolean

I have just moved from flask-sqlalchemy to just sqlalchemy. And I have started getting below issue. Issue 1 : I have two models class Candidate(db.Model): __tablename__ = 'candidate' id = db.Column(db.Integer, primary_key=True) …
Hussain
  • 5,057
  • 6
  • 45
  • 71
3
votes
1 answer

Python- sqlalchemy.exc.ArgumentError:could not assemble any primary key columns for mapped table

I'm using Flask + Alembic + Sqlalchemy. I want to create two table and use it. First, i run alembic script : """add table insurace_bands and insurace_discounts Revision ID: 39ba7ec3428 Revises: 18468fbedbac Create Date: 2015-05-12…
DonerKebab
  • 500
  • 4
  • 13
3
votes
1 answer

change database migrations from sqlalchemy-migrate to Flask-Migrate

I have an web app base on miguel flask tutorial So I use sqlalchemy-migrate for database and Now I should Use Alembic in migration How can I do the configuration? is there any way that I can change from sqlalchemy-migrate to Flask-Migrate?(coz my…
Linda
  • 551
  • 2
  • 7
  • 16
3
votes
1 answer

How can I programmatically set the 'target_metadata' required by Alembic for use with the command API?

I'm managing database migrations with Alembic and would like to use the default files generated by alembic init without any modifications to env.py (e.g., setting target_metadata) or alembic.ini (e.g., setting sqlalchemy.url) to manage migrations of…
orome
  • 45,163
  • 57
  • 202
  • 418
3
votes
1 answer

How can I get a Redshift dialect working in Python with SQLAlchemy and Alembic for migrations?

I get the following error when I try to "alembic upgrade +1", which is meant for making database migrations. File "/home/jason/redshift/env/lib/python3.4/site-packages/sqlalchemy/engine/default.py", line 436, in do_execute …
Josh.F
  • 3,666
  • 2
  • 27
  • 37
3
votes
1 answer

Preserve data in migrations

With this setup: -Development environment -Flask -SQLAlchemy -Postgres -Possibility Alembic If I have a database with some tables populated with random data. As far as I know the Flask-Migrate, that will use Alembic, will not preserve the data,…
user2990084
  • 2,699
  • 9
  • 31
  • 46