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

Python TypeError: option values must be strings in Migrator

Migrator Error Traceback (most recent call last): File > "/home/arjdu-d-1890/PycharmProjects/git-local-repo/example-flask-crud/venv/bin/flask", > line 8, in > sys.exit(main()) File…
0
votes
1 answer

AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'alter'

I'm working on a project that has both older sqlalchemy-migrate-based migrations and newer alembic-based migrations. I'm trying to remove the former. Ripping it out was easy enough but I'm seeing the following failure when I run some tests after…
stephenfin
  • 1,447
  • 3
  • 20
  • 41
0
votes
1 answer

Is there one configure to config in env to migrate correctly when changing column's name within Alembic?

I used alembic to migrate database in flask, it seems like alembic didn't give correct way to migrate data, it just created new column and removed old column, it caused that data may be dropped, here is the code. docker-compose -f docker-compose.yml…
kalends
  • 3
  • 2
0
votes
0 answers

FlaskMigrate not detecting new column added

I'm new to sqlalchemy and flask. I inherited a project in which I need to add new columns to a table (new fields to a model). Here is what the model looks like. class Area(db.Model): __tablename__ = 'areas' id = db.Column(db.Integer,…
mikejay93
  • 11
  • 2
0
votes
1 answer

Flask Migrate for Multiple Database

To give a bit of the background on our application, we had already configured a database for existing endpoints in the app. Now there is a new requirement to add endpoints to the same application talking to a different database. As stated in the…
0
votes
2 answers

Alembic inverting upgrade/downgrade (Flask-SQLAlchemy)

I've been struggling with Alembic lately, I don't know why it is inverting the correct upgrade/downgrade changes. I've created 2 new fields (about_me, last_seen) in the User model, run 'flask db migrate' and then looking at the version file I can…
0
votes
0 answers

Delay between consecutive SQL statements when using Alembic on Jenkins

I have a problem with delays between consecutive SQL statements when Alembic executes a migration script's upgrade() function on Jenkins: def upgrade(): op.execute("DELETE FROM employee WHERE name='John';") #John also has its primary key ID…
Quentin
  • 1,090
  • 13
  • 24
0
votes
0 answers

Flask-SQLAlchemy Alembic migrations

I'm trying to do database migrations on postgresDB using Flask-SQLAlchemy and alembic. models.py import datetime from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class TestOne(db.Model): __tablename__ = 'test_one' __bind_key__ =…
0
votes
1 answer

alembic - how to share functions across revisions?

Alembic doesn't support replaceable objects like views so we often have to write a custom function in revision that executes creation of them. Is there a way to share these functions across revisions instead of copy-pasting over and over?
nobody
  • 270
  • 2
  • 14
0
votes
1 answer

Order of Alembic's autogenerated revision file

I have quite a convoluted database schema that I'm hoping to version using Alembic. I am using a declarative_base to create my models, and my env.py looks like: from logging.config import fileConfig import os import sys from alembic import…
KeironO
  • 179
  • 1
  • 9
0
votes
0 answers

Alembic few modules to single database, with specific file migrations

We need to build a large application that split to multiple modules. Each module has own alembic version table, and in each module we generated the alembic migration, but the problem when I generate a migration file, inside it generate drop of all…
0
votes
1 answer

Python Flask SQL Alchemy Segmentation Fault

Just got a new laptop and cannot get a solution to run the DB migration. It works perfectly fine on another machine and also on a Ubuntu server. Running the DB migration results in: [1] 7379 segmentation fault pipenv run flask db upgrade I used…
Elliot Reeve
  • 901
  • 4
  • 21
  • 39
0
votes
1 answer

I have a database in sqlalchemy and I'm trying to change the values of a column in the database to lowercase during the database migration

The FeedSnapshot table has a column username whose values I want to force to all lowercase. Also when I try to use the update..set commnad, I get an error that 'update' has no attribute 'set'. Is there an equivalent of the command that I can use…
0
votes
1 answer

Add relationship backref order_by with alembic

I recently added Alembic to my Flask project and now my SQLAlchemy relationship sorting with order_by is no longer working. I believe this is because the migration file that is run is not picking up the order_by argument and I'm not sure how to get…
AJordan
  • 3
  • 4
0
votes
1 answer

Is it possible to set up a template for an Alembic .py upgrade script?

When I run alembic revision -m '...', Alembic generates a new .py script with the default body looking like this: from alembic import op # revision identifiers, used by Alembic. revision = '1ce7873ac4ced2' down_revision =…
Quentin
  • 1,090
  • 13
  • 24