Permalink
Browse files

Adds initial migration support using sqlalchemy-migrate

  • Loading branch information...
1 parent c71cc3d commit 4971a1c47a079e77cf81e75c3a130cebd936ac2d @zerok committed Oct 15, 2011
View
@@ -0,0 +1,4 @@
+This is a database migration repository.
+
+More information at
+http://code.google.com/p/sqlalchemy-migrate/
No changes.
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+from migrate.versioning.shell import main
+main(debug='False')
@@ -0,0 +1,20 @@
+[db_settings]
+# Used to identify which repository this database is versioned under.
+# You can use the name of your project.
+repository_id=pygraz_website
+
+# The name of the database table used to track the schema version.
+# This name shouldn't already be used by your project.
+# If this is changed once a database is under version control, you'll need to
+# change the table name in each database too.
+version_table=migrate_version
+
+# When committing a change script, Migrate will attempt to generate the
+# sql for all supported databases; normally, if one of them fails - probably
+# because you don't have that database installed - it is ignored and the
+# commit continues, perhaps ending successfully.
+# Databases in this list MUST compile successfully during a commit, or the
+# entire commit will fail. List the databases your application will actually
+# be using to ensure your updates to that database work properly.
+# This must be a list; example: ['postgres','sqlite']
+required_dbs=[]
@@ -0,0 +1,75 @@
+from sqlalchemy import *
+from migrate import *
+
+
+meta = MetaData()
+
+
+meetup = Table('meetup', meta,
+ Column('id', Integer, Sequence('meetup_id_seq'), primary_key=True),
+ Column('start', DateTime(timezone=False)),
+ Column('end', DateTime(timezone=False)),
+ Column('location', String(255)),
+ Column('address', String(255)),
+ Column('notes', Text)
+ )
+
+tweet = Table(
+ 'tweet', meta,
+ Column('id', Integer, Sequence('tweet_id_seq'), primary_key=True),
+ Column('text', Text),
+ Column('external_id', String, unique=True),
+ Column('created_at', DateTime(timezone=False)),
+ Column('in_reply_to_status_id', String),
+ Column('in_reply_to_screen_name', String)
+ )
+
+sessionidea = Table('sessionidea', meta,
+ Column('id', Integer, Sequence('sessionidea_id_seq'), primary_key=True),
+ Column('summary', String(255)),
+ Column('details', Text),
+ Column('url', String(1024), nullable=True),
+ Column('author_id', Integer, ForeignKey('user.id')),
+ Column('meetup_id', Integer, ForeignKey('meetup.id'))
+ )
+
+sessionidea_vote = Table('sessionidea_vote', meta,
+ Column('id', Integer, Sequence('sessionideavote_id_seq'), primary_key=True),
+ Column('user_id', Integer, ForeignKey('user.id')),
+ Column('sessionidea_id', Integer, ForeignKey('sessionidea.id')),
+ Column('value', Integer)
+ )
+
+user = Table(
+ 'user', meta,
+ Column('id', Integer, Sequence('user_id_seq'), primary_key=True),
+ Column('username', String, unique=True),
+ Column('email', String),
+ Column('is_admin', Boolean, nullable=True, default=False)
+ )
+
+openid = Table(
+ 'openID', meta,
+ Column('id', String, primary_key=True),
+ Column('user_id', Integer, ForeignKey('user.id'))
+ )
+
+
+def upgrade(migrate_engine):
+ meta.bind = migrate_engine
+ user.create()
+ openid.create()
+ meetup.create()
+ sessionidea.create()
+ tweet.create()
+ sessionidea_vote.create()
+
+
+def downgrade(migrate_engine):
+ meta.bind = migrate_engine
+ sessionidea_vote.drop()
+ tweet.drop()
+ sessionidea.drop()
+ meetup.drop()
+ openid.drop()
+ user.drop()
No changes.
View
@@ -11,3 +11,4 @@ gunicorn
fabric
Flask-SQLAlchemy
psycopg2
+sqlalchemy-migrate

0 comments on commit 4971a1c

Please sign in to comment.