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:

92 questions
6
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
  • 26,469
  • 11
  • 56
  • 73
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
  • 15,338
  • 6
  • 52
  • 73
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
  • 58,044
  • 75
  • 235
  • 407
5
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
  • 81
  • 1
  • 2
  • 10
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,114
  • 8
  • 37
  • 43
4
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
  • 1,581
  • 1
  • 13
  • 20
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
  • 6,424
  • 3
  • 38
  • 45
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,235
  • 7
  • 27
  • 38
3
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,253
  • 5
  • 30
  • 45
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…
egesuato
  • 1,075
  • 2
  • 13
  • 27
3
votes
1 answer

Getting sqlalchemy.migrate to rename a column with primary key

I am trying to rename a column in a table which has the primary key constraint to an another name and add a new column with a new type becoming the primary key. So currently I have : TABLE ( `id` VARCHAR(36) PRIMARY_KEY, ) table; I want to…
Chmouel Boudjnah
  • 2,413
  • 3
  • 23
  • 25
3
votes
0 answers

Sqlalchemy-migrate create column with default values

I'm using SQLAlchemy-migrate 0.6.1 to handle versioning of my mysql database. The link points to the documentation. But they seem to have removed the docs for 0.6.1. I'm trying to add a new column with a foreignkey constraint to a table like…
Carl
  • 720
  • 7
  • 17
2
votes
1 answer

Adding columns to existing tables using sqlalchemy

Is there a way to add columns to an existing table using sqlalchemy? Looking at options, it seems like sqlalchemy-migrate is the popular option, but it seems to be designed around static changes. It also requires setting up the DB to support…
Logick
  • 161
  • 1
  • 3
  • 13
2
votes
1 answer

Flask-migrate No changes in schema detected

I am trying to understand how flask and sqlalchemy works.Below is my app structure init.py contains import os from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from flask_login import…
2
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
  • 117
  • 8