-
Notifications
You must be signed in to change notification settings - Fork 978
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...xy/model/migrate/versions/0167_add_job_to_input_dataset_collection_element_association.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
Migration script to add a new job_to_input_dataset_collection_element table to track job inputs. | ||
""" | ||
from __future__ import print_function | ||
|
||
import logging | ||
|
||
from sqlalchemy import Column, ForeignKey, Integer, MetaData, Table, Unicode | ||
|
||
log = logging.getLogger(__name__) | ||
metadata = MetaData() | ||
|
||
job_to_input_dataset_collection_element_table = Table( | ||
"job_to_input_dataset_collection_element", metadata, | ||
Column("id", Integer, primary_key=True), | ||
Column("job_id", Integer, ForeignKey("job.id"), index=True), | ||
Column("dataset_collection_element_id", Integer, ForeignKey("dataset_collection_element.id"), index=True), | ||
Column("name", Unicode(255))) | ||
|
||
|
||
def upgrade(migrate_engine): | ||
print(__doc__) | ||
metadata.bind = migrate_engine | ||
metadata.reflect() | ||
|
||
try: | ||
job_to_input_dataset_collection_element_table.create() | ||
except Exception: | ||
log.exception("Creating job_to_input_dataset_collection_element table failed") | ||
|
||
|
||
def downgrade(migrate_engine): | ||
metadata.bind = migrate_engine | ||
metadata.reflect() | ||
|
||
try: | ||
job_to_input_dataset_collection_element_table.drop() | ||
except Exception: | ||
log.exception("Dropping job_to_input_dataset_collection_element table failed") |