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

Alembic syntax for SQL "in" operator

i need the alembic syntax for an operation like select id from table1 where id not in (select id from table2) there doesn't seem to be any documentation anywhere on this. any pointers would be helpful
Jules
  • 1,071
  • 2
  • 18
  • 37
0
votes
1 answer

Alembic migration acting on different versions of same database

I am trying to use alembic migrations to act on different versions of the same database. An example would be that I have two databases, one live and one for testing. Each of them might be in different states of migration. For one, the test database…
Tammo Heeren
  • 1,966
  • 3
  • 15
  • 20
0
votes
1 answer

`Programing Error, Table doesn't exist` using alembic bulk_insert

I am trying to use alembic to create a new table and use bulk_insert to add new entries. I am following the bulk_insert example here. Here is the code that I am running: from alembic import op import sqlalchemy as sa from sqlalchemy.sql import…
realityinabox
  • 593
  • 1
  • 5
  • 14
0
votes
0 answers

What is the distinction between "import module.submodule" and "from module import submodule"?

I'm running into this behavior when I import a module in the config script I'm using to drive alembic. The script is dynamically loaded from the filesystem by a module installed in my virtualenv, which seems like the only situation where this issue…
Dan Monego
  • 9,637
  • 6
  • 37
  • 72
0
votes
0 answers

sql - how to add a rank column to an existing table

I have the following table: my_table = sa.sql.table('my_table', sa.Column('id', sa.BigInteger), sa.Column('employee_id', sa.BigInteger) ) and I want to add a 'rank' column using alembic. The addition itself is pretty straight forward using…
Ofir
  • 1,565
  • 3
  • 23
  • 41
0
votes
1 answer

sqlalchemy schema: there is no unique constraint matching given keys for referenced table

I'm trying to create 2 tables using SQLAlchemy models that are identical in structure but distinct in purpose, the Whitelist and Blacklist which also reference a Magazine (not shown). They both fkey to an instance of a Campaign (say a political…
Chrispy
  • 1,300
  • 3
  • 11
  • 25
0
votes
1 answer

Flask & SqlAlchemy - alembic session.add_all() results in AttributeError: 'bool' object has no attribute 'clear' error

I'm trying to insert some data as part of deployment. I've created following alembic revision script revision = '59891ffc8502' down_revision = '349540cf9cef' from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import mysql from…
Arek S
  • 4,239
  • 4
  • 24
  • 33
0
votes
1 answer

flask-migrate wants to drop my indeces

I've got a Flask app with the following models: class User(db.Model, UserMixin): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(64), unique=True, index=True) password_hash =…
treznick
  • 25
  • 3
0
votes
1 answer

AttributeError: 'int' object has no attribute '_compiler_dispatch'

I am using the flask-sqlalchemy extension with alembic for migrations. When I try to add a new migration file and upgrade the schema to the latest one, I get the following error: AttributeError: 'int' object has no attribute…
Kevin
  • 6,539
  • 5
  • 44
  • 54
0
votes
1 answer

Flask migration error

I've got an application build on flask and I wanted to create a new migration for it today. When I run $python manage.py db upgrade i got the message raise util.CommandError('Only a single head is supported. The…
shanky
  • 751
  • 1
  • 16
  • 46
0
votes
2 answers

Alembic not able to import flask application ORM models

Use case: I'm attempting to create a migration script that will create a table (which will make a many to many relationship) and then populate that table with foreign keys from the database. To do this I'm attempting to load my flask applications…
AlexLordThorsen
  • 8,057
  • 5
  • 48
  • 103
0
votes
1 answer

Alembic/Flask-migrate doesn't recognise database structure

I have a Flask-based application and I'm trying to enable migrations to be able to manage database structural changes. My database is not empty and contains tables and records before I started with alembic and flask-migrate. First, I tried to use…
lawicko
  • 7,246
  • 3
  • 37
  • 49
0
votes
1 answer

Alembic / Flask-migrate migration on Heroku runs but does not create tables

I am attempting to deploy a Flask app to Heroku. I have pushed to Heroku and can access my login page but any call to the db gives an OperationalError: 2014-01-29T12:12:31.801772+00:00 app[web.1]: OperationalError: (OperationalError) no such table:…
kendlete
  • 214
  • 4
  • 13
0
votes
1 answer

alembic will allow sql files under versions?

In sqlalchemy-migrate repos, we can place .sql files instead of .py files under versions folder for upgrading/downgrading database schema. 001_mysql_downgrade.sql 001_mysql_upgrade.sql Is the same feature exist in alembic? If yes can someone plz…
Murali Mopuru
  • 6,086
  • 5
  • 33
  • 51
0
votes
1 answer

Alembic Migrations for Flask

I have been trying to get the Alembic migration system configured for my Flask app for the past 7 hours with no success. Any ideas as to what I am doing wrong? I have tried all the solutions I found here, but they did not seem to work for me. I get…
GangstaGraham
  • 8,865
  • 12
  • 42
  • 60
1 2 3
56
57