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

Is there an SQLAlchemy equivalent of django-evolution?

All I want is to have a workflow somewhat similar to: Add django_evolution to the INSTALLED_APPS for your project Run ./manage.py syncdb Make modifications to the model files in your project Run ./manage.py evolve --hint --execute Which is super…
ubershmekel
  • 11,864
  • 10
  • 72
  • 89
6
votes
1 answer

Where can I find good examples or tutorials for sqlalchemy-migrate

In this thread someone pointed me to use sqlalchemy-migrate to help with a fast-changing web application using sqlalchemy. However a Do It Yourself method was also recommended consisting in manually writing CSV columns for the new database schema,…
ascobol
  • 7,554
  • 7
  • 49
  • 70
6
votes
1 answer

SQLAlchemy Migrate - Can I add (or modify) a column to a certain position of an existing table?

I want to add a column to a certain position of an existing table or move one of the columns. But I can't find any method in Sqlalchemy-migrate. I want to know methods equivalent following MySQL queries in sqlalchemy-migrate ALTER TABLE tablename…
Daehee Kim
  • 61
  • 3
5
votes
2 answers

Upgrading Pyramid/SQLAlchemy web apps

I've got a standard run of the mill Pylons Pyramid application, that uses SQLAlchemy for its database persistence. I have set up an SQLAlchemy-migrate repo and have it functioning, but I really want to have the ability to use paster to upgrade and…
X-Istence
  • 16,324
  • 6
  • 57
  • 74
5
votes
2 answers

how to set unique value for each row on alembic migration

I added a unique attribute uid for MyModel model: class MyModel(db.Model): ... uid = db.Column(db.String(50), nullable=False) ... __table_args__ = (UniqueConstraint('uid', name='unique_uid'),) I have a migration: def upgrade(): …
Alexey Egorov
  • 2,221
  • 2
  • 18
  • 21
5
votes
2 answers

Alembic downgrade doesn't seem to understand the meta data

The model.py looks like this: import datetime from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String, Numeric, ForeignKey, DateTime, Boolean from sqlalchemy import create_engine from sqlalchemy.orm…
Houman
  • 64,245
  • 87
  • 278
  • 460
4
votes
0 answers

Python SqlAlchemy-Migrate Error adding a ForeignKeyConstraint

I have a changeset script in which I'm trying to add a foreign key constraint to an existing table column. It looks something like: from sqlalchemy import * from migrate import * import datetime metadata = MetaData() registrations =…
rr.
  • 6,484
  • 9
  • 40
  • 48
4
votes
0 answers

Postgres 'collation "NOCASE" for encoding "UTF8" does not exist'

I am trying to setup a fresh database on a new system but I got this error: sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedObject) collation "NOCASE" for encoding "UTF8" does not exist LINE 4: email VARCHAR(120) COLLATE "NOCASE" NOT…
maydin
  • 195
  • 1
  • 3
  • 15
4
votes
2 answers

Error creating table with foreign key constraint using SQLAlchemy-Migrate

I'm building an app in python. I'm using sqlalchemy-migrate to track my database schema. I have a table, user_category, which has two columns: id and name. I'm trying to create a user table with a foreign key to the user_category table. My change…
hellsgate
  • 5,905
  • 5
  • 32
  • 47
4
votes
1 answer

Python/SQLAlchemy migration - ValueError: need more than 3 values to unpack when migrating

I'm following Miguel Grinberg's excellent Flask Mega-Tutorial and using his database creation and migration scripts (found here) but I'm running into a problem when changing a column in one of my models. The old model was: class Classes(db.Model): …
Aaron D
  • 7,540
  • 3
  • 44
  • 48
4
votes
2 answers

One-to-one relationship in Flask

I'm trying to create a one-to-one relationship in Flask using SqlAlchemy. I followed this previous post and I created the classes like ones below: class Image(db.Model): __tablename__ = 'image' image_id = db.Column(db.Integer, primary_key =…
Thiago
  • 694
  • 3
  • 12
  • 26
4
votes
2 answers

Pyramid schema migrations

I'm using "vanilla" Pyramid 1.4 under Gentoo and I want to make changes to my tables and commit them without having to delete the table (and all of it's data) and then recreate it. I've heard the solution to this is schema migrations. Being a…
q3d
  • 3,473
  • 8
  • 34
  • 39
3
votes
0 answers

database migration using alembic or flask (Python)

i am creating a database using SQLAlchemy and I Need to do Migration to my data as i am using df_sql function for converting my csv into dataframe and then to tables in sqlalchemy. As i do this i need to do Migration to add new column and values…
shankar ram
  • 157
  • 1
  • 13
3
votes
1 answer

SQLAlchemy migration table already exist

I just got started using flask-migrate and I encounter some problems with it. In order to get myself familiarized with it, I started a new project with a mock MySQL database. I run the migration as following export FLASK_APP=run.py flask db…
Terchila Marian
  • 2,225
  • 3
  • 25
  • 48
3
votes
0 answers

py2exe and sqlalchemy-migrate

I'm using python 2.6, sqlalchemy 0.6 for a tiny desktop application. Also i'm using py2exe and sqlalchemy-migrate and i'm trying to integrate migrate inside the exe. In this way when the user starts the application the database gets automatically…
semantic-dev
  • 1,095
  • 3
  • 14
  • 27