1 | """ |
---|
2 | This migration script adds a user preferences table to Galaxy. |
---|
3 | """ |
---|
4 | |
---|
5 | from sqlalchemy import * |
---|
6 | from migrate import * |
---|
7 | |
---|
8 | import datetime |
---|
9 | now = datetime.datetime.utcnow |
---|
10 | |
---|
11 | import logging |
---|
12 | log = logging.getLogger( __name__ ) |
---|
13 | |
---|
14 | metadata = MetaData( migrate_engine ) |
---|
15 | |
---|
16 | def display_migration_details(): |
---|
17 | print "" |
---|
18 | print "This migration script adds a user preferences table to Galaxy." |
---|
19 | print "" |
---|
20 | |
---|
21 | |
---|
22 | # New table to support user preferences. |
---|
23 | |
---|
24 | UserPreference_table = Table( "user_preference", metadata, |
---|
25 | Column( "id", Integer, primary_key=True ), |
---|
26 | Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ), |
---|
27 | Column( "name", Unicode( 255 ), index=True), |
---|
28 | Column( "value", Unicode( 1024 ) ) ) |
---|
29 | |
---|
30 | def upgrade(): |
---|
31 | display_migration_details() |
---|
32 | metadata.reflect() |
---|
33 | try: |
---|
34 | UserPreference_table.create() |
---|
35 | except Exception, e: |
---|
36 | print str(e) |
---|
37 | log.debug( "Creating user_preference table failed: %s" % str( e ) ) |
---|
38 | |
---|
39 | def downgrade(): |
---|
40 | metadata.reflect() |
---|
41 | try: |
---|
42 | UserPreference_table.drop() |
---|
43 | except Exception, e: |
---|
44 | print str(e) |
---|
45 | log.debug( "Dropping user_preference table failed: %s" % str( e ) ) |
---|