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
0
votes
1 answer

Generate alembic migration scripts from existing tables schema

I have tables and it's schema. I neither have the database nor Sqlalchemy models. How do I generate alembic first version script with this information? P.S. I could create a database with existing schema if that could be of help to get the alembic…
0
votes
1 answer

Flask-Migrate: index has table none

I am trying to create the migration: python manage.py db migrate Getting the following stack trace: I tracked it down to the [2019-08-12 17:09:11,197] INFO in __init__: Project API INFO [alembic.runtime.migration] Context impl OracleImpl. INFO …
Lev
  • 999
  • 2
  • 10
  • 26
0
votes
1 answer

Alembic fails to upgrade database because of missing VARCHAR length and cannot correct

I ran flask db upgrade and received the error VARCHAR requires a length on dialect mysql So I corrected my VARCHAR by adding the length like this username = db.Column(db.VARCHAR(256)) Then I ran flask db migrate and get the error Target database…
Jason
  • 11,709
  • 9
  • 66
  • 82
0
votes
1 answer

alembic autogenerate after primary key rename failing

Against better judgment, I decided to rename the primary column in my databases from id to key, as I didn't want to clash with Python's id function. I managed to use alembic to rename the column by using batch migrations, as I'm using an SQLite…
Tsvi M
  • 334
  • 1
  • 12
0
votes
1 answer

error NoSuchTableError: - when drop table. Flask

In his application he created alternately three models and the connections between them: class Operation(db.Model): __tablename__ = "operation" id = db.Column(db.Integer, primary_key=True) date_operation = db.Column(db.DateTime) …
Ambasador
  • 365
  • 3
  • 14
0
votes
1 answer

How can I migrate a table with data in a table which got a new datetime column which is non-nullable?

I've added a column registered_on = db.Column(db.DateTime, nullable=False) to my users table. The migration which was automatically created is def upgrade(): # ### commands auto generated by Alembic - please adjust! ### ... …
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
0
votes
1 answer

Analyze command for SQLAlchemy alembic

The way I perform migration for a database is 1. run command alembic upgrade head to upgrade the local postgres to match database schema. 2. update the model to add new column (or index) to a table. 3. then run alembic revision --autogenerate -m…
0
votes
3 answers

Why do I keep getting an error root cannot locate revision identified by '1cccee45d6e7'?

I am trying to get my database up and running for flask and there is an issue when I type flask db migrate -m "users table". It keeps giving me an error that says this: ERROR [root] Error: Can't locate revision identified by '1cccee45d6e7' I tried…
Connor Smith
  • 1
  • 1
  • 2
0
votes
1 answer

Error when initiating Data Base in Apache Airflow

I have built a local environment on my computer to test Dags in airflow however when I got to initiate the database in the terminal with airflow initdb I am prompted with an error message. The message has to do with the package Alembic and reads…
declac
  • 39
  • 8
0
votes
1 answer

Run migrations using db.create_all()

I needed to write my own Trigger to be able to update some search vectors in my Postgres database and alembic/ Sqlalchemy weren't able to autogenerate these. For that I added my custom SQL into a migrations file. Using my dev machine everything…
Leonleon1
  • 165
  • 2
  • 8
0
votes
1 answer

Alembic migrations - script persistence between two deployments

I have problem with running automated migrations with alembic library (I use raw alembic library). So this is setup of the application: I have scheduler (python script which calculates something and then stores it in database) and flask REST API…
maro
  • 67
  • 6
0
votes
2 answers

flask migrate - not detecting addition of new column

Having a tough time getting Flask-migrate to detect new column in a table. My guess is that something isn't getting imported, or I'm importing things in the incorrect order. The app is instantiated by a __init__.py file. The overall directory of the…
themantalope
  • 1,040
  • 11
  • 42
0
votes
0 answers

Executing Truly Raw SQL in SQLAlchemy in Python

I have data I'm loading into PostgreSQL with SQLAlchemy Core. The data is in SQL. It contains JSON which looks like the param syntax in SQLAlchemy, i.e. :foo. How do I execute the SQL in a way that's truly raw, i.e. with no parsing of its contents…
jennykwan
  • 2,631
  • 1
  • 22
  • 33
0
votes
1 answer

Alembic sqlalchemy.exc.NoReferencedColumnError: (Using Flask-sqlalchemy and Flask-Migrate)

Alembic keeps giving me this error when I try to migrate my schema even though the initial migration went without a hitch. sqlalchemy.exc.NoReferencedColumnError: Could not initialize target column for ForeignKey 'dataset.datasetid' on table…
0
votes
1 answer

How to add a column to existing table in flask

Done as follows but no column is added. Migrate database python manage.py db migrate Edit migrations/versions/{version}_.py def upgrade(): from alembic import op op.add_column('table_name', Column('column_name', INTEGER) ) Update…
user
  • 1,220
  • 1
  • 12
  • 31