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

How to annotate query set with count of field in generic relation with Django ORM using Django 1.6

class Purchase(models.Model): content_type = models.ForeignKey(ContentType) content_uid = UUIDField(auto=False,unique=False) content = generic.GenericForeignKey('content_type', 'content_uid') user = models.ForeignKey(User) class…
Sojan KR
  • 21
  • 4
2
votes
1 answer

Pass postgresql schema to alembic migration

I have a postgresql database and I want to pass postgresql schema name in DSN, like this: postgresql://login:password@postgreshost/dbname?schema=my_schema. I know that I can specify the schema keyword in migration operations like op.create_table.…
Pehat
  • 1,573
  • 1
  • 10
  • 24
2
votes
1 answer

How to specify a full text search index (MySQL) in an Alembic migration?

I'm using Flask-Migrate for a project in which the target database is MySQL-compatible Aurora. I added a full-text index to a model using Menzhuo's SQLAlchemy fulltext search module: class Post(db.Model, FullText, Serializable): __tablename__ =…
Ray Toal
  • 86,166
  • 18
  • 182
  • 232
2
votes
0 answers

alembic won't execute raw sql that sets delimiter

I'm trying to create a trigger in my database by executing a raw SQL string in alembic's upgrade function. However I get a sqlalchemy.exc.ProgrammingError when running upgrade: Running this in my migration script: def upgrade(): connection =…
lsimmons
  • 677
  • 1
  • 8
  • 22
2
votes
1 answer

Docker: Building an image that depends on another image to be running

My objective is to build a Docker image that includes MySQL prefilled with the tables and data produced by an Alembic migration. Unfortunately, Alembic can't produce the necessary data without an active MySQL instance, nor can it independently…
Mikkel
  • 1,192
  • 9
  • 22
2
votes
0 answers

.abc (Alembic) 3d model with animation won't play in SceneKit preview

I have been able to get models from .dae (COLLADA) files with animation working in the SceneKit preview (which is the best way I know to test if an animation is compatible). I have a freelancer who made an animation for me originally in Cinema 4D,…
Brian Schermerhorn
  • 1,361
  • 1
  • 15
  • 22
2
votes
0 answers

Flask-Migrate: Table Already Exists Error

From an empty schema on postgres I'm able to create a single table (blog) using flask-migrate using: python migrate_test.py db init python migrate_test.py db migrate python migrate_test.py db upgrade This creates the table fine. Then I do the…
blountdj
  • 599
  • 1
  • 11
  • 23
2
votes
1 answer

Table sequence id not incrementing after applying alembic migration

I am facing a weird problem using alembic migration. I am using Postgres as DB. I have written an alembic revision where I am inserting some data in a table(There is already some data in the table before migration). The issue is the migration runs…
A J
  • 3,684
  • 2
  • 19
  • 24
2
votes
0 answers

Use alembic.ini for configuring db connection charset

I am performing migrations using alembic. Configuration is of course stored in the alembic.ini file. I would like to have the encoding used when running the migrations as a configurable parameter. Is there a field that can be used within alembic.ini…
pkaramol
  • 16,451
  • 43
  • 149
  • 324
2
votes
2 answers

How to use Alembic with a SSL connection?

I use Alembic to manage my migrations. My database is on AWS, and I want to connect it with SSL. In my alembic.ini I have the lines [production] script_location = alembic_prod sqlalchemy.url =…
DaMaill
  • 875
  • 8
  • 17
2
votes
0 answers

Does Flask-Migrate handle manually defined sequences?

I'am building a flask-sqlalchemy data model and had success creating the tables and adding data to the tables in the database. I recently decided to include Flask-Migrate around the app so I can track changes conveniently. Using Flask-Migrate along…
2
votes
1 answer

SQLite to PostgreSQL data-only transfer (to maintain alembic functionality)

There are a few questions and answers already on PostgreSQL import (as well as the specific SQLite->PostgreSQL situation). This question is about a specific corner-case. Background I have an existing, in-production web-app written in python…
Ng Oon-Ee
  • 1,193
  • 1
  • 10
  • 26
2
votes
1 answer

How to call flask migrate api in script

I have a database db. I want to judge if flask_migrate has created tables in db. If not, upgrade db. There are commands, but no examples about calling migrate, upgrade in python script. The test files in flask_migrate also run commands: (o, e, s) =…
Jojo
  • 89
  • 8
2
votes
1 answer

how to drop foreign key constraint for a foreign key with no name on alembic?

I have a table which i created as shown below op.create_table('test', sa.Column('userid', sa.String(length=60), nullable=False), sa.Column('page_id', sa.Integer(), nullable=False), …
nocturnal
  • 395
  • 2
  • 6
  • 15
2
votes
1 answer

[Flask][Alembic] Impossible to set target_metadata in env.py

I'm trying to build a webapp with flask, Mysql, SQLAlchemy and Alembic. But I'm not able to understand how imports work in python and how to set up my target_metadata to be able to use revision --autogenerate Here is my directory's tree: My…
Bastien
  • 158
  • 1
  • 11