|
| 1 | +"""Instant assets sharing |
| 2 | +
|
| 3 | +Revision ID: c2f12b313b48 |
| 4 | +Revises: f7fcb58b99cd |
| 5 | +Create Date: 2022-03-01 13:48:42.551162 |
| 6 | +
|
| 7 | +""" |
| 8 | + |
| 9 | +""" |
| 10 | + OpenVINO DL Workbench |
| 11 | + Migration: Instant assets sharing |
| 12 | +
|
| 13 | + Copyright (c) 2022 Intel Corporation |
| 14 | +
|
| 15 | + LEGAL NOTICE: Your use of this software and any required dependent software (the “Software Package”) is subject to |
| 16 | + the terms and conditions of the software license agreements for Software Package, which may also include |
| 17 | + notices, disclaimers, or license terms for third party or open source software |
| 18 | + included in or with the Software Package, and your use indicates your acceptance of all such terms. |
| 19 | + Please refer to the “third-party-programs.txt” or other similarly-named text file included with the Software Package |
| 20 | + for additional details. |
| 21 | + You may obtain a copy of the License at |
| 22 | + https://software.intel.com/content/dam/develop/external/us/en/documents/intel-openvino-license-agreements.pdf |
| 23 | +""" |
| 24 | +from alembic import op |
| 25 | +import sqlalchemy as sa |
| 26 | + |
| 27 | +# revision identifiers, used by Alembic. |
| 28 | +revision = 'c2f12b313b48' |
| 29 | +down_revision = 'f7fcb58b99cd' |
| 30 | +branch_labels = None |
| 31 | +depends_on = None |
| 32 | + |
| 33 | + |
| 34 | +def upgrade(): |
| 35 | + op.rename_table('downloadable_artifacts', 'shared_artifacts') |
| 36 | + op.drop_column('create_profiling_bundle_jobs', 'tab_id') |
| 37 | + |
| 38 | + op.execute("UPDATE artifacts SET type='downloadable_artifact' WHERE type='downloadable_artifacts';") |
| 39 | + |
| 40 | + op.execute("UPDATE shared_artifacts SET job_id=create_profiling_bundle_jobs.job_id FROM create_profiling_bundle_jobs WHERE shared_artifacts.id=create_profiling_bundle_jobs.bundle_id;") |
| 41 | + # Connect bundles from downloadable_artifacts with jobs throw job_id instead of bundle_id |
| 42 | + op.execute("UPDATE shared_artifacts SET job_id=create_profiling_bundle_jobs.job_id FROM create_profiling_bundle_jobs WHERE shared_artifacts.id=create_profiling_bundle_jobs.bundle_id;") |
| 43 | + op.drop_constraint('create_profiling_bundle_jobs_bundle_id_fkey', 'create_profiling_bundle_jobs', type_='foreignkey') |
| 44 | + op.drop_column('create_profiling_bundle_jobs', 'bundle_id') |
| 45 | + |
| 46 | + op.execute("UPDATE shared_artifacts SET job_id=create_int8_calibration_bundle_jobs.job_id FROM create_int8_calibration_bundle_jobs WHERE shared_artifacts.id=create_int8_calibration_bundle_jobs.bundle_id;") |
| 47 | + op.drop_constraint('create_int8_calibration_bundle_jobs_bundle_id_fkey', 'create_int8_calibration_bundle_jobs', |
| 48 | + type_='foreignkey') |
| 49 | + op.drop_column('create_int8_calibration_bundle_jobs', 'bundle_id') |
| 50 | + |
| 51 | + op.execute("UPDATE shared_artifacts SET job_id=create_accuracy_bundle_jobs.job_id FROM create_accuracy_bundle_jobs WHERE shared_artifacts.id=create_accuracy_bundle_jobs.bundle_id;") |
| 52 | + op.drop_constraint('create_accuracy_bundle_jobs_bundle_id_fkey', 'create_accuracy_bundle_jobs', type_='foreignkey') |
| 53 | + op.drop_column('create_accuracy_bundle_jobs', 'bundle_id') |
| 54 | + |
| 55 | + op.execute("UPDATE shared_artifacts SET job_id=create_annotate_dataset_bundle_jobs.job_id FROM create_annotate_dataset_bundle_jobs WHERE shared_artifacts.id=create_annotate_dataset_bundle_jobs.bundle_id;") |
| 56 | + op.drop_constraint('create_annotate_dataset_bundle_jobs_bundle_id_fkey', 'create_annotate_dataset_bundle_jobs', |
| 57 | + type_='foreignkey') |
| 58 | + op.drop_column('create_annotate_dataset_bundle_jobs', 'bundle_id') |
| 59 | + |
| 60 | + op.execute("UPDATE shared_artifacts SET job_id=create_per_tensor_bundle_jobs.job_id FROM create_per_tensor_bundle_jobs WHERE shared_artifacts.id=create_per_tensor_bundle_jobs.bundle_id;") |
| 61 | + op.drop_constraint('create_per_tensor_bundle_jobs_bundle_id_fkey', 'create_per_tensor_bundle_jobs', |
| 62 | + type_='foreignkey') |
| 63 | + op.drop_column('create_per_tensor_bundle_jobs', 'bundle_id') |
| 64 | + |
| 65 | + op.add_column('parse_dev_cloud_result_jobs', sa.Column('are_results_obtained', sa.Boolean(), nullable=True)) |
| 66 | + op.alter_column('parse_dev_cloud_result_jobs', 'result_artifact_id', existing_type=sa.INTEGER(), nullable=True) |
| 67 | + |
| 68 | + op.drop_constraint('parse_dev_cloud_result_jobs_result_artifact_id_fkey', 'parse_dev_cloud_result_jobs', |
| 69 | + type_='foreignkey') |
| 70 | + op.create_foreign_key(None, 'parse_dev_cloud_result_jobs', 'shared_artifacts', ['result_artifact_id'], ['id']) |
| 71 | + |
| 72 | + op.drop_constraint('trigger_dev_cloud_jobs_job_bundle_id_fkey', 'trigger_dev_cloud_jobs', type_='foreignkey') |
| 73 | + op.drop_constraint('trigger_dev_cloud_profiling_jobs_setup_bundle_id_fkey', 'trigger_dev_cloud_jobs', |
| 74 | + type_='foreignkey') |
| 75 | + op.create_foreign_key(None, 'trigger_dev_cloud_jobs', 'shared_artifacts', ['job_bundle_id'], ['id']) |
| 76 | + op.create_foreign_key(None, 'trigger_dev_cloud_jobs', 'shared_artifacts', ['setup_bundle_id'], ['id']) |
| 77 | + op.drop_constraint('upload_artifact_to_target_jobs_artifact_id_fkey', 'upload_artifact_to_target_jobs', |
| 78 | + type_='foreignkey') |
| 79 | + op.create_foreign_key(None, 'upload_artifact_to_target_jobs', 'shared_artifacts', ['artifact_id'], ['id']) |
| 80 | + |
| 81 | + # ### end Alembic commands ### |
| 82 | + |
| 83 | + |
| 84 | +def downgrade(): |
| 85 | + raise NotImplementedError(f'Downgrade is not implemented for the {revision} migration') |
0 commit comments