| 1 | """ |
|---|
| 2 | Migration script to create a table for page-user share association. |
|---|
| 3 | """ |
|---|
| 4 | |
|---|
| 5 | from sqlalchemy import * |
|---|
| 6 | from sqlalchemy.orm import * |
|---|
| 7 | from migrate import * |
|---|
| 8 | from migrate.changeset import * |
|---|
| 9 | |
|---|
| 10 | import logging |
|---|
| 11 | log = logging.getLogger( __name__ ) |
|---|
| 12 | |
|---|
| 13 | metadata = MetaData( migrate_engine ) |
|---|
| 14 | db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) ) |
|---|
| 15 | |
|---|
| 16 | PageUserShareAssociation_table = Table( "page_user_share_association", metadata, |
|---|
| 17 | Column( "id", Integer, primary_key=True ), |
|---|
| 18 | Column( "page_id", Integer, ForeignKey( "page.id" ), index=True ), |
|---|
| 19 | Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ) |
|---|
| 20 | ) |
|---|
| 21 | |
|---|
| 22 | def upgrade(): |
|---|
| 23 | print __doc__ |
|---|
| 24 | metadata.reflect() |
|---|
| 25 | |
|---|
| 26 | # Create stored_workflow_tag_association table. |
|---|
| 27 | try: |
|---|
| 28 | PageUserShareAssociation_table.create() |
|---|
| 29 | except Exception, e: |
|---|
| 30 | print str(e) |
|---|
| 31 | log.debug( "Creating page_user_share_association table failed: %s" % str( e ) ) |
|---|
| 32 | |
|---|
| 33 | def downgrade(): |
|---|
| 34 | metadata.reflect() |
|---|
| 35 | |
|---|
| 36 | # Drop workflow_tag_association table. |
|---|
| 37 | try: |
|---|
| 38 | PageUserShareAssociation_table.drop() |
|---|
| 39 | except Exception, e: |
|---|
| 40 | print str(e) |
|---|
| 41 | log.debug( "Dropping page_user_share_association table failed: %s" % str( e ) ) |
|---|