Questions tagged [sqlalchemy-migrate]

Schema migration tools for SQLAlchemy, designed to support an agile approach to database design, and make it easier to keep development and production databases in sync, as schema changes are required.

Inspired by Ruby on Rails’ migrations, SQLAlchemy Migrate provides a way to deal with database schema changes in SQLAlchemy projects. Migrate was started as part of Google’s Summer of Code by Evan Rosson, mentored by Jonathan LaCour. The project was taken over by a small group of volunteers when Evan had no free time for the project. It is now hosted as a Google Code project. During the hosting change the project was renamed to SQLAlchemy Migrate.

Python 2.4-2.7 is supported.

Resources:

97 questions
73
votes
4 answers

alembic util command error can't find identifier

I'm trying to use alembic to handle local migrations on my project. It worked the first time, but then I needed to delete the folder and restart.(don't ask why, I just had to) I'm following this tutorial and I run the command python manage.py db…
56
votes
2 answers

sqlalchemy postgresql enum does not create type on db migrate

I develop a web-app using Flask under Python3. I have a problem with postgresql enum type on db migrate/upgrade. I added a column "status" to model: class Banner(db.Model): ... status = db.Column(db.Enum('active', 'inactive', 'archive',…
51
votes
3 answers

Is it worth using sqlalchemy-migrate ?

I have a web application using sqlalchemy (within Pylons). I need to effiently change the schema to be able to change the production version at least on a daily basis, maybe more, without losing the data. I have played a little bit with…
ascobol
  • 7,554
  • 7
  • 49
  • 70
28
votes
2 answers

Update column content during Alembic migration

Suppose my db model contains an object User: Base = declarative_base() class User(Base): __tablename__ = 'users' id =…
Jens
  • 8,423
  • 9
  • 58
  • 78
19
votes
3 answers

How to write alter column name migrations with sqlalchemy-migrate?

I'm trying to alter a column name. First attempt was with this script: meta = MetaData() users = Table('users', meta, Column('id', Integer, primary_key=True), Column('name', String(50), unique=True), Column('email', String(120),…
PEZ
  • 16,821
  • 7
  • 45
  • 66
18
votes
8 answers

Cannot complete Flask-Migration

I've setup a local Postgres DB with SQLAlchemy and cannot commit my first entry. I keep on getting this error... ProgrammingError: (ProgrammingError) relation "user" does not exist LINE 1: INSERT INTO "user" (name, email, facebook_id,…
Suraj Kapoor
  • 1,615
  • 4
  • 22
  • 34
18
votes
1 answer

Default value ignored in non-nullable column

I'm trying to create a new boolean, non-nullable column (with default=True) in a table with the following SQL alchemy script: from sqlalchemy import MetaData, Table, Boolean, Column def upgrade(migrate_engine): meta =…
phihag
  • 278,196
  • 72
  • 453
  • 469
16
votes
3 answers

Flask-Migrate sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column

I am using Flask-Migrate in my application, with the following models: listpull/models.py from datetime import datetime from listpull import db class Job(db.Model): id = db.Column(db.Integer, primary_key=True) list_type_id =…
11
votes
3 answers

SQLAlchemy-Migrate or Alembic deletes data when renaming model

I am using SQLAlchemy-Migrate to manage migrations for my PostgreSQL database. I changed the __tablename__ for a model, and running the migration changed the name in the database, but all the rows in the table were deleted. How can I rename a model…
Nurjan
  • 5,889
  • 5
  • 34
  • 54
11
votes
3 answers

Update an sqlite database schema with sqlalchemy and elixir

I've created a python application which uses elixir/sqlalchemy to store data. The second release of the software requires any files created in the previous version to be updated in order to add/delete tables and columns. My question is: how can I…
Jon
  • 9,815
  • 9
  • 46
  • 67
9
votes
1 answer

Flask Database Issue

I am using this tutorial as a guideline. http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iv-database I want to have Categories that can heave multiple Products. Similar to how he has a User with multiple Posts. when I open up the…
Siecje
  • 3,594
  • 10
  • 32
  • 50
8
votes
2 answers

Why am I getting SQLAlchemy Error "__table_args__ value must be a tuple, dict, or None"

I have the following SQLAlchemy Model. It has been successfully migrated to the database: class MyClassA(db.Model, Timestamp): a_id = db.Column(db.Integer, nullable=False, primary_key=True) b_id = db.Column(db.Integer, db.ForeignKey(C.c_id),…
Saqib Ali
  • 11,931
  • 41
  • 133
  • 272
7
votes
1 answer

sqlalchemy: "Neither 'InstrumentedAttribute' object nor 'Comparator' object has an attribute" error

I've added a table to a database using sqlalchemy and sqlalchemy-migrate, and when I run unit tests on unrelated code that hits the database, I get the following error: Traceback (most recent call last): File…
Lorin Hochstein
  • 57,372
  • 31
  • 105
  • 141
7
votes
2 answers

Sqlalchemy Foreign key relationship error while creating tables

Im creating tables using sqlalchemy and some of these tables has more than one foreign key relationship.Below is the code. I'm getting error: sqlalchemy.exc.NoForeignKeysError: Can't find any foreign key relationships between 'project' and…
Mithu
  • 101
  • 1
  • 2
  • 10
7
votes
1 answer

Test whether DB migration result are consistent with (ORM)? models

I am using migrate to create SQL database schema and populate it with initial data. Later SQLAlchemy is used to work with this DB. How could I test that my SQLAlchemy models are relevant/correct for real DB schema generated by migrate?
Roman Bodnarchuk
  • 29,461
  • 12
  • 59
  • 75
1
2 3 4 5 6 7