[2] | 1 | """ |
---|
| 2 | Migration script to add the post_job_action_association table. |
---|
| 3 | """ |
---|
| 4 | |
---|
| 5 | from sqlalchemy import * |
---|
| 6 | from migrate import * |
---|
| 7 | from migrate.changeset import * |
---|
| 8 | from galaxy.model.custom_types import * |
---|
| 9 | |
---|
| 10 | import datetime |
---|
| 11 | now = datetime.datetime.utcnow |
---|
| 12 | |
---|
| 13 | import logging |
---|
| 14 | log = logging.getLogger( __name__ ) |
---|
| 15 | |
---|
| 16 | metadata = MetaData( migrate_engine ) |
---|
| 17 | |
---|
| 18 | PostJobActionAssociation_table = Table("post_job_action_association", metadata, |
---|
| 19 | Column("id", Integer, primary_key=True), |
---|
| 20 | Column("post_job_action_id", Integer, ForeignKey("post_job_action.id"), index=True, nullable=False), |
---|
| 21 | Column("job_id", Integer, ForeignKey("job.id"), index=True, nullable=False)) |
---|
| 22 | |
---|
| 23 | def upgrade(): |
---|
| 24 | print __doc__ |
---|
| 25 | metadata.reflect() |
---|
| 26 | try: |
---|
| 27 | PostJobActionAssociation_table.create() |
---|
| 28 | except Exception, e: |
---|
| 29 | log.debug( "Creating PostJobActionAssociation table failed: %s" % str( e ) ) |
---|
| 30 | |
---|
| 31 | def downgrade(): |
---|
| 32 | # Load existing tables |
---|
| 33 | metadata.reflect() |
---|
| 34 | try: |
---|
| 35 | PostJobActionAssociation_table.drop() |
---|
| 36 | except Exception, e: |
---|
| 37 | log.debug( "Dropping PostJobActionAssociation table failed: %s" % str( e ) ) |
---|