"""rename_accuracy_report_entities

Revision ID: 06bb10328413
Revises: <PASSWORD>
Create Date: 2021-08-19 08:08:32.783847

"""

"""
 OpenVINO DL Workbench
 Migration: Rename accuracy report entities

 Copyright (c) 2021 Intel Corporation

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
      http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
"""
from alembic import op

# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '8406ca2e35e5'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(constraint_name='accuracy_classification_report_image_classes_report_id_fkey',
                       table_name='accuracy_classification_report_image_classes', type_='foreignkey')
    op.drop_constraint(constraint_name='accuracy_detection_report_image_classes_report_id_fkey',
                       table_name='accuracy_detection_report_image_classes', type_='foreignkey')
    op.drop_constraint(constraint_name='accuracy_tensor_distance_report_image_classes_report_id_fkey',
                       table_name='accuracy_tensor_distance_report_image_classes', type_='foreignkey')

    op.rename_table('accuracy_classification_report_image_classes', 'classification_accuracy_report_entities')
    op.rename_table('accuracy_detection_report_image_classes', 'detection_accuracy_report_entities')
    op.rename_table('accuracy_tensor_distance_report_image_classes', 'tensor_distance_accuracy_report_entities')

    op.rename_table('accuracy_report', 'accuracy_reports')
    op.rename_table('accuracy_tensor_distance_report', 'tensor_distance_accuracy_reports')

    op.create_foreign_key('classification_accuracy_report_entities_report_id_fkey',
                          'classification_accuracy_report_entities', 'accuracy_reports', ['report_id'], ['id'])
    op.create_foreign_key('detection_accuracy_report_entities_report_id_fkey', 'detection_accuracy_report_entities',
                          'accuracy_reports', ['report_id'], ['id'])
    op.create_foreign_key('tensor_distance_accuracy_report_entities_report_id_fkey',
                          'tensor_distance_accuracy_report_entities', 'accuracy_reports', ['report_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(constraint_name='classification_accuracy_report_entities_report_id_fkey',
                       table_name='classification_accuracy_report_entities', type_='foreignkey')
    op.drop_constraint(constraint_name='detection_accuracy_report_entities_report_id_fkey',
                       table_name='detection_accuracy_report_entities', type_='foreignkey')
    op.drop_constraint(constraint_name='tensor_distance_accuracy_report_entities_report_id_fkey',
                       table_name='tensor_distance_accuracy_report_entities', type_='foreignkey')

    op.rename_table('classification_accuracy_report_entities', 'accuracy_classification_report_image_classes')
    op.rename_table('detection_accuracy_report_entities', 'accuracy_detection_report_image_classes')
    op.rename_table('tensor_distance_accuracy_report_entities', 'accuracy_tensor_distance_report_image_classes')

    op.rename_table('accuracy_reports', 'accuracy_report')
    op.rename_table('tensor_distance_accuracy_reports', 'accuracy_tensor_distance_report')

    op.create_foreign_key('accuracy_classification_report_image_classes_report_id_fkey',
                          'accuracy_classification_report_image_classes', 'accuracy_report', ['report_id'], ['id'])
    op.create_foreign_key('accuracy_detection_report_image_classes_report_id_fkey',
                          'accuracy_detection_report_image_classes', 'accuracy_report', ['report_id'], ['id'])
    op.create_foreign_key('accuracy_tensor_distance_report_image_classes_report_id_fkey',
                          'accuracy_tensor_distance_report_image_classes', 'accuracy_report', ['report_id'], ['id'])
    # ### end Alembic commands ###

"""rename_accuracy_report_entities

Revision ID: 06bb10328413
Revises: <PASSWORD>
Create Date: 2021-08-19 08:08:32.783847

"""

"""
 OpenVINO DL Workbench
 Migration: Rename accuracy report entities

 Copyright (c) 2021 Intel Corporation

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
      http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
"""
from alembic import op

# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '8406ca2e35e5'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(constraint_name='accuracy_classification_report_image_classes_report_id_fkey',
                       table_name='accuracy_classification_report_image_classes', type_='foreignkey')
    op.drop_constraint(constraint_name='accuracy_detection_report_image_classes_report_id_fkey',
                       table_name='accuracy_detection_report_image_classes', type_='foreignkey')
    op.drop_constraint(constraint_name='accuracy_tensor_distance_report_image_classes_report_id_fkey',
                       table_name='accuracy_tensor_distance_report_image_classes', type_='foreignkey')

    op.rename_table('accuracy_classification_report_image_classes', 'classification_accuracy_report_entities')
    op.rename_table('accuracy_detection_report_image_classes', 'detection_accuracy_report_entities')
    op.rename_table('accuracy_tensor_distance_report_image_classes', 'tensor_distance_accuracy_report_entities')

    op.rename_table('accuracy_report', 'accuracy_reports')
    op.rename_table('accuracy_tensor_distance_report', 'tensor_distance_accuracy_reports')

    op.create_foreign_key('classification_accuracy_report_entities_report_id_fkey',
                          'classification_accuracy_report_entities', 'accuracy_reports', ['report_id'], ['id'])
    op.create_foreign_key('detection_accuracy_report_entities_report_id_fkey', 'detection_accuracy_report_entities',
                          'accuracy_reports', ['report_id'], ['id'])
    op.create_foreign_key('tensor_distance_accuracy_report_entities_report_id_fkey',
                          'tensor_distance_accuracy_report_entities', 'accuracy_reports', ['report_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(constraint_name='classification_accuracy_report_entities_report_id_fkey',
                       table_name='classification_accuracy_report_entities', type_='foreignkey')
    op.drop_constraint(constraint_name='detection_accuracy_report_entities_report_id_fkey',
                       table_name='detection_accuracy_report_entities', type_='foreignkey')
    op.drop_constraint(constraint_name='tensor_distance_accuracy_report_entities_report_id_fkey',
                       table_name='tensor_distance_accuracy_report_entities', type_='foreignkey')

    op.rename_table('classification_accuracy_report_entities', 'accuracy_classification_report_image_classes')
    op.rename_table('detection_accuracy_report_entities', 'accuracy_detection_report_image_classes')
    op.rename_table('tensor_distance_accuracy_report_entities', 'accuracy_tensor_distance_report_image_classes')

    op.rename_table('accuracy_reports', 'accuracy_report')
    op.rename_table('tensor_distance_accuracy_reports', 'accuracy_tensor_distance_report')

    op.create_foreign_key('accuracy_classification_report_image_classes_report_id_fkey',
                          'accuracy_classification_report_image_classes', 'accuracy_report', ['report_id'], ['id'])
    op.create_foreign_key('accuracy_detection_report_image_classes_report_id_fkey',
                          'accuracy_detection_report_image_classes', 'accuracy_report', ['report_id'], ['id'])
    op.create_foreign_key('accuracy_tensor_distance_report_image_classes_report_id_fkey',
                          'accuracy_tensor_distance_report_image_classes', 'accuracy_report', ['report_id'], ['id'])
    # ### end Alembic commands ###

rename_accuracy_report_entities  Revision ID: 06bb10328413 Revises: <PASSWORD> Create Date: 2021-08-19 08:08:32.783847 OpenVINO DL Workbench  Migration: Rename accuracy report entities   Copyright (c) 2021 Intel Corporation   Licensed under the Apache License, Version 2.0 (the "License");  you may not use this file except in compliance with the License.  You may obtain a copy of the License at       http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software  distributed under the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions and  limitations under the License. # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###