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

how to chain two migrations through migraions ids and to create a linear chain to collapse the branches?

I deployed my flask app into heroku. When I run this command I get an error. heroku run python manage.py deploy This is the error message: raise util.CommandError('Only a single head is supported. The ' alembic.util.CommandError: Only a single…
0
votes
2 answers

How to delete table using Alembic?

I want to delete a bunch of code from my application including several models. I tried deleting the file that defines the models and then did an Alemic autogenerate but the generated migration file did not appear to remove the corresponding…
Duke Dougal
  • 24,359
  • 31
  • 91
  • 123
0
votes
0 answers

how can I use a column that is not a Primary Key as a Foreign Key?

This might be a dumb question, but I can't find anything that indicates that you can't, however, when I try it, it does not work. I have an example of such an instance, but I can't reproduce the results. Using SQLAlchemy, here is the working…
Renier
  • 1,523
  • 4
  • 32
  • 60
0
votes
1 answer

SQLAlchemy Partial Index with composite keys having the same name

I am using Python 2.7 and SQLAlchemy 0.9.8 and trying to use partial indexes. I have two tables (just the relevant part) class DesignerRange __tablename__ = 'designer_ranges' shortcode = Column(Unicode(12)) class Design …
aprado
  • 31
  • 2
  • 6
0
votes
1 answer

Alembic Migration: How to remove polymorphic Identity

I have the following setup class Content(Base): """Content object""" __tablename__ = "content" id = Column(Integer, primary_key=True) name = Column(Unicode(255),unique=True, nullable=False) title = Column(Unicode(255)) body =…
ephraimbuddy
  • 331
  • 2
  • 10
0
votes
1 answer

Recover database schema from Alembic migrations

I recently reinstalled my OS and lost some old data from a local postgre db. But I backed up all the migration files using Alembic. And now I just want to restore the database schema from the migration files, not data. Is that possible?
benjaminz
  • 3,118
  • 3
  • 35
  • 47
0
votes
1 answer

Flask-Migrate Error: 'ConfigParser.NoSectionError: No section: 'alembic''

For the last few weeks I've been building a website mostly based on Miguel Grinberg's book 'Flask Web Development'. This is my 'manage.py' file for reference: import os from app import create_app, db from app.models import User, Role, Permission,…
Josh Kraushaar
  • 369
  • 5
  • 17
0
votes
1 answer

Is there a way to force alembic to track imported models?

I'm trying to write a pyramid app that uses the cd34/apex project for authentication. In it, the models for auth are already part of the apex project, which are imported in at runtime. Alembic seems to ignore those models, even if I import them in…
Peter Grace
  • 569
  • 5
  • 20
0
votes
1 answer

Sqlite3 schema upgrade using alembic

I have C++ application (Linux) which uses sqlite3 db through APIs. Currently DB is shipped along with binaries in RPM. This DB has all required tables already. My application does not try to change any schema while running. Now I have to support db…
ND1125
  • 31
  • 2
  • 7
0
votes
1 answer

Alembic Second Database First Revision

My goal is to add a second database to my current project, using alembic. I have the default alembic folder, and using 'alembic init alembic_second' I created a second folder structure. I modified the env.py in the second folder and the root…
lnhubbell
  • 3,304
  • 5
  • 17
  • 22
0
votes
1 answer

HDF5 OSX pre-built

Does anyone have or know of a pre-built HDF5 on OSX somewhere? The one I compiled myself gives me some mismatch errors and does not work in some cases. I mainly need it to use it with Alembic.
Yasin
  • 609
  • 1
  • 10
  • 22
0
votes
1 answer

SQLAlchemy alembic AmbiguousForeignKeysError for declarative type but not for equivalent non-declarative type

I have the following alembic migration: revision = '535f7a49839' down_revision = '46c675c68f4' from alembic import op import sqlalchemy as sa from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker from…
Andrew Magee
  • 6,506
  • 4
  • 35
  • 58
0
votes
2 answers

how to create auto-generated file from last revision in Alembic

I'm following this tutorial.. and the initial auto generate is perfect.. it basically creates the migration file with the upgrade and downgrade methods just fine. so let's say this is the migration file's revision number: 3e96cf22770b.. all of my…
abbood
  • 23,101
  • 16
  • 132
  • 246
0
votes
1 answer

import a module init_data in alembic

I'm newbie in python + scrapy + alembic. I finding a way to insert some init data in alembic using bulk_insert function. my code: (direct insert) op.bulk_insert('table', [ { 'id' : 1, 'website': 'http://example', 'xpath_pagination':…
Tue Vo
  • 323
  • 2
  • 3
  • 14
0
votes
1 answer

Alembic Error: "Only a single head supported so far..."

When running the alembic revision command to generate a new revision script I get the following (not particularly helpful) error: $ alembic -c .ini revision -m "example message" Only a single head supported so far... The implication…
Chris W.
  • 37,583
  • 36
  • 99
  • 136