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
0
votes
1 answer

Broke my Flask-sqlalchemy sqlite db instance

While testing my Flask applications functionality i somehow broke my db by editing my models during up/downgrading. I am using Migrate for this purpose but i am fairly new to it. which leads to my question: How do I completely reset my db(Migrate…
0
votes
1 answer

alembic autogenerates creates empty migration but generates table

I followed the documentation from Alembic to auto-generate migrations. My project structure looks like this: alembic/ versions/ env.py README script.py.mako data/ __init__.py db.py models.py alembic.ini app.db I made changes to env.py…
Tyrion
  • 175
  • 1
  • 13
0
votes
0 answers

Postgresql partition management with sqlalchemy and flask migrate

I'm working on a multi-tenant system, where any number of tenants can signup to the system and manage their data. Whenever a tenant signs up, a new partition of tables with a partition name which ends with his id is created, and he'll be managing…
0
votes
1 answer

SQLAlchemy objects don't recognize new columns after DB schema was changed

I have a local DB set up for which I create object-relational mapping with SQLAlchemy objects. Everything was fine until I changed the schema of the DB - including adding a new column to one of the tables. Now I keep…
0
votes
1 answer

AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'alter'

I'm working on a project that has both older sqlalchemy-migrate-based migrations and newer alembic-based migrations. I'm trying to remove the former. Ripping it out was easy enough but I'm seeing the following failure when I run some tests after…
stephenfin
  • 1,340
  • 2
  • 17
  • 37
0
votes
0 answers

Flask SQLAlchemy -- handling reference tables with fixed records

This is really a general question about how to handle reference tables in ORMs, but for my specific use-case I'm leveraging Flask-SQLAlchemy. What are best practices when handling reference tables in ORMs? For example, say you have a reference table…
0
votes
0 answers

Alembic few modules to single database, with specific file migrations

We need to build a large application that split to multiple modules. Each module has own alembic version table, and in each module we generated the alembic migration, but the problem when I generate a migration file, inside it generate drop of all…
0
votes
2 answers

Add a column to existing class of sqlalchemy

I have a parent class that generates a unique id and a child class having a username. class Ids(object): id = Column(Integer, Sequence('res_id_seq'), primary_key=True) class Names(Ids, base): username = Column(String(50)) # I have…
0
votes
0 answers

Connect Flask SQLAlchemy template to an existing database - Hybrid Alembic & Automap

I'm connecting a Flask app to an existing MySQL database. I let SQLAlchemy's db.create() function build and manage a new table USER normally - see this in the models.py file below. SQLAlchemy can control it with its ORM and Alembic setups this way.…
Edward
  • 109
  • 1
  • 10
0
votes
2 answers

How does it matter the schema defined using sqlalchemy, if Alembic has already defined the schema?

I'm using alembic for database migration. And using sqlalchemy to connect to the database using python. In alembic, we define table schema as the first version and this the actual one which creates the schema. For example, I have given schema like…
venkat
  • 353
  • 2
  • 12
0
votes
0 answers

How to handle psycopg2 undefined table error when migrating postgres db to heroku?

I have reviewed at least 20 stackover flow answers, plus lots of blog posts, and I am at a complete loss for how to migrate my local postgres db to heroku for a simple flask app. I have been following along with several different tutorials and…
buchmayne
  • 146
  • 1
  • 9
0
votes
1 answer

Why am I getting a 'not unique' error when referencing a primary key?

I have two models - Station: class Station(db.Model): """Measurement station""" __tablename__ = "station" reference = db.Column(db.Text, nullable=False, primary_key=True) name = db.Column(db.Text, nullable=False, primary_key=True) …
0
votes
0 answers

Subquery with SQLAlchemy with groupby and orderby

I am working on change my python code from db.engine.execute to proper SqlAlchmy manner, But I am stuck with a query having subquery with group_by and order_by. select * from (select * from table1 where value='a' or value='b' or value='c' order by…
Harsh Sharma
  • 9,634
  • 2
  • 13
  • 24
0
votes
0 answers

sqlalchemy-migrate does not find change file for version

I am evaluating SQLAlchemy-migrate as a database migration tool. My db_version is 0, and the repository version is 1. $ python manage.py db_version --url=postgresql://localhost:5432/my_db 0 $ python manage.py version 1 and I only have one…
0
votes
1 answer

Tweet Scheduler based on Flask Megatutorial: Issues with getting fields of flask-sqlalchemy databse

I'm in the process of modifying the Flask app created in following along Miguel Grinberg's Flask Mega Tutorial such that it is possible to post tweets. I have imported tweepy for accessing the twitter api and modified the databases to hold the…