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

MariaDb Json Support

Am using windows 10, I am running MariaDB 10.1.18 and it says JSON was supported from 10.0.1 but when am trying to do flask db migrations it's throwing error ? json not support.
Shiva
  • 467
  • 2
  • 4
  • 12
1
vote
1 answer

Replace integer id field with uuid

I need to replace the default integer id in my model with an uuid. The problem is that it's beeing used in another model (foreignkey). Any idea on how to perform this operation without losing data? class A(Base): __tablename__ = 'a' b_id =…
user2091046
  • 585
  • 1
  • 8
  • 20
1
vote
1 answer

Ambiguous foreign key in self-referencing table [SQLAlchemy/Alembic]

I have a model classes defined like this. The idea is that that Person will hold general information about people as well as reference to it's "sub-classes": Woman and Men as parents. Woman and Men will hold information specific for that gender. I'm…
Jakub Tesárek
  • 136
  • 1
  • 6
1
vote
2 answers

Using Alembic Migrations with multiple projects

I have two Flask applications using Flask-Migrate and Alembic. There are three tables, with one table that is shared between the two Flask applications, and is represented by shared_models.py I am running into the difficulty that the shared table…
George L
  • 1,673
  • 2
  • 26
  • 39
1
vote
1 answer

alembic db migration concurrently

I have multiple flask apps connected to the same database backend for high availability purposes. There is a problem when app instances try to migrate database concurrently using alembic! What's the best way to prevent it?
Robinho
  • 1,011
  • 2
  • 10
  • 17
1
vote
0 answers

Alembic stamp command issues with sqlite in-memory db

I'm experiencing some problems with alembic's stamp command and using sqlite in-memory databases for testing. Tests that work perfectly with file-based sqlite dbs fail with OperationalError: (OperationalError) no such table. I'm stamping during…
Matthew Trevor
  • 14,354
  • 6
  • 37
  • 50
1
vote
0 answers

Advanced migration between Databases using Python, SQLAlchemy, and Alembic

--- UPDATED to be more clear --- I have quite the task ahead of me, and I am hoping Alembic and SQLAlchemy can do what I need. I want to develop a desktop application that helps migrate data from one SQLite database to a completely different model…
Dovy
  • 1,278
  • 10
  • 19
1
vote
0 answers

Issue with seed data in Alembic

I have been using SQLAlchemy for year now. And I use Alembic for migrating changes. I am also using alembic to seed data. Take an example of the authorization seeds. def upgrade(): op.bulk_insert(Role.__table__, ROLE_LIST) …
Hussain
  • 5,057
  • 6
  • 45
  • 71
1
vote
1 answer

flask migrate automatically changing database

I'm new to Flask and Flask-Migrate. When running python manage.py db migrate -m "explanation", whatever change I made to models.py gets automatically applied to the database (in this case, adding a column to some table). I thought changes were only…
JMS
  • 1,039
  • 4
  • 12
  • 20
1
vote
0 answers

How to support old schema versions with SQLAlchemy?

My application works with huge database contents for which we can't always migrate to the latest database schema version we designed at software upgrade time. And yes, we're using database migration tools (Alembic), but this doesn't yet allow us to…
gertvdijk
  • 24,056
  • 6
  • 41
  • 67
1
vote
1 answer

Alembic SqlAlchemy Postgres "NameError: name 'String' is not defined" trying to add Array(String) fields

The Model is below plus error message below that. I am trying to create some array columns using Alembic but getting NameError: name 'String' is not defined. Any help valued. thanks! from sqlalchemy import Column, String, Integer, DateTime from…
Duke Dougal
  • 24,359
  • 31
  • 91
  • 123
1
vote
1 answer

Flask migrate command using Ansible throws a maximum recursion depth exceeded error

My flask app uses alembic for managing database migrations. While trying to deploy the app using Ansible, it runs into a Runtime Error with maximum recursion depth exceeded when the Ansible playbook encounters the command python manage.py db…
maverick93
  • 143
  • 1
  • 4
  • 13
1
vote
2 answers

Alembic: 'relation "public.alembic_version" does not exist' when using `version_table_schema`

I'm writing some custom code for Alembic to keep my database always updated in my dev environment for a project. The project involves a database with the following: A public schema for shared data A single schema per client "database" One schema…
zashu
  • 747
  • 1
  • 7
  • 22
1
vote
2 answers

alembic: adding id field to existing table

This is a follow on to my previous question. Basically I have a table that has 2 foreign key links into two other table. But I think the best way is to add a primary key to the table itself so that it becomes: id, int, primary foreign_id_1, int,…
lang2
  • 11,433
  • 18
  • 83
  • 133
1
vote
1 answer

Specify join condition in SQLalchemy ORM without foreign key

I have two models in SQLAlchemy that I had automatically joining on a foreign key, like so: class Parent(Base): __tablename__ = 'parents' id = Column(Integer, primary_key=True) name = Column(String(300), nullable=False) metadata_id…
Eli
  • 36,793
  • 40
  • 144
  • 207