generated from bcgov/EPIC.scaffold
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from dinesh-aot/COMP-280
Link case files
- Loading branch information
Showing
9 changed files
with
337 additions
and
21 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
compliance-api/migrations/versions/c353afd11883_case_file_link.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,103 @@ | ||
"""case file link | ||
Revision ID: c353afd11883 | ||
Revises: 9ca9ebdf5b64 | ||
Create Date: 2024-12-05 13:52:31.894453 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'c353afd11883' | ||
down_revision = '9ca9ebdf5b64' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('case_file_links_version', | ||
sa.Column('id', sa.Integer(), autoincrement=False, nullable=False, comment='The unique identifier of the case file link'), | ||
sa.Column('source_case_id', sa.Integer(), autoincrement=False, nullable=True), | ||
sa.Column('target_case_id', sa.Integer(), autoincrement=False, nullable=True), | ||
sa.Column('created_date', sa.DateTime(), autoincrement=False, nullable=True), | ||
sa.Column('updated_date', sa.DateTime(), autoincrement=False, nullable=True), | ||
sa.Column('created_by', sa.String(length=100), autoincrement=False, nullable=True), | ||
sa.Column('updated_by', sa.String(length=100), autoincrement=False, nullable=True), | ||
sa.Column('is_active', sa.Boolean(), server_default='t', autoincrement=False, nullable=True), | ||
sa.Column('is_deleted', sa.Boolean(), server_default='f', autoincrement=False, nullable=True), | ||
sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False), | ||
sa.Column('end_transaction_id', sa.BigInteger(), nullable=True), | ||
sa.Column('operation_type', sa.SmallInteger(), nullable=False), | ||
sa.Column('source_case_id_mod', sa.Boolean(), server_default=sa.text('false'), nullable=False), | ||
sa.Column('target_case_id_mod', sa.Boolean(), server_default=sa.text('false'), nullable=False), | ||
sa.Column('created_date_mod', sa.Boolean(), server_default=sa.text('false'), nullable=False), | ||
sa.Column('updated_date_mod', sa.Boolean(), server_default=sa.text('false'), nullable=False), | ||
sa.Column('created_by_mod', sa.Boolean(), server_default=sa.text('false'), nullable=False), | ||
sa.Column('updated_by_mod', sa.Boolean(), server_default=sa.text('false'), nullable=False), | ||
sa.Column('is_active_mod', sa.Boolean(), server_default=sa.text('false'), nullable=False), | ||
sa.Column('is_deleted_mod', sa.Boolean(), server_default=sa.text('false'), nullable=False), | ||
sa.PrimaryKeyConstraint('id', 'transaction_id') | ||
) | ||
with op.batch_alter_table('case_file_links_version', schema=None) as batch_op: | ||
batch_op.create_index(batch_op.f('ix_case_file_links_version_end_transaction_id'), ['end_transaction_id'], unique=False) | ||
batch_op.create_index(batch_op.f('ix_case_file_links_version_operation_type'), ['operation_type'], unique=False) | ||
batch_op.create_index(batch_op.f('ix_case_file_links_version_source_case_id'), ['source_case_id'], unique=False) | ||
batch_op.create_index(batch_op.f('ix_case_file_links_version_target_case_id'), ['target_case_id'], unique=False) | ||
batch_op.create_index(batch_op.f('ix_case_file_links_version_transaction_id'), ['transaction_id'], unique=False) | ||
|
||
op.create_table('case_file_links', | ||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='The unique identifier of the case file link'), | ||
sa.Column('source_case_id', sa.Integer(), nullable=False), | ||
sa.Column('target_case_id', sa.Integer(), nullable=False), | ||
sa.Column('created_date', sa.DateTime(), nullable=False), | ||
sa.Column('updated_date', sa.DateTime(), nullable=True), | ||
sa.Column('created_by', sa.String(length=100), nullable=False), | ||
sa.Column('updated_by', sa.String(length=100), nullable=True), | ||
sa.Column('is_active', sa.Boolean(), server_default='t', nullable=False), | ||
sa.Column('is_deleted', sa.Boolean(), server_default='f', nullable=False), | ||
sa.ForeignKeyConstraint(['source_case_id'], ['case_files.id'], name='source_case_id_case_files_id_fk'), | ||
sa.ForeignKeyConstraint(['target_case_id'], ['case_files.id'], name='target_case_id_case_files_id_fk'), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
with op.batch_alter_table('case_file_links', schema=None) as batch_op: | ||
batch_op.create_index(batch_op.f('ix_case_file_links_source_case_id'), ['source_case_id'], unique=False) | ||
batch_op.create_index(batch_op.f('ix_case_file_links_target_case_id'), ['target_case_id'], unique=False) | ||
|
||
with op.batch_alter_table('case_files', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('link_case_file_id', sa.Integer(), nullable=True, comment='The case file to link to')) | ||
batch_op.create_foreign_key('casefile_link_link_case_file_id_fk', 'case_files', ['link_case_file_id'], ['id']) | ||
|
||
with op.batch_alter_table('case_files_version', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('link_case_file_id', sa.Integer(), autoincrement=False, nullable=True, comment='The case file to link to')) | ||
batch_op.add_column(sa.Column('link_case_file_id_mod', sa.Boolean(), server_default=sa.text('false'), nullable=False)) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('case_files_version', schema=None) as batch_op: | ||
batch_op.drop_column('link_case_file_id_mod') | ||
batch_op.drop_column('link_case_file_id') | ||
|
||
with op.batch_alter_table('case_files', schema=None) as batch_op: | ||
batch_op.drop_constraint('casefile_link_link_case_file_id_fk', type_='foreignkey') | ||
batch_op.drop_column('link_case_file_id') | ||
|
||
with op.batch_alter_table('case_file_links', schema=None) as batch_op: | ||
batch_op.drop_index(batch_op.f('ix_case_file_links_target_case_id')) | ||
batch_op.drop_index(batch_op.f('ix_case_file_links_source_case_id')) | ||
|
||
op.drop_table('case_file_links') | ||
with op.batch_alter_table('case_file_links_version', schema=None) as batch_op: | ||
batch_op.drop_index(batch_op.f('ix_case_file_links_version_transaction_id')) | ||
batch_op.drop_index(batch_op.f('ix_case_file_links_version_target_case_id')) | ||
batch_op.drop_index(batch_op.f('ix_case_file_links_version_source_case_id')) | ||
batch_op.drop_index(batch_op.f('ix_case_file_links_version_operation_type')) | ||
batch_op.drop_index(batch_op.f('ix_case_file_links_version_end_transaction_id')) | ||
|
||
op.drop_table('case_file_links_version') | ||
# ### end Alembic commands ### |
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
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
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
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
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
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
Oops, something went wrong.