mike cullerton f097b394b6 Migration script for DB changes.
Create new relationship tables for IRBEVENT and IRB_STATUS.
Change columns to relationships
2021-06-18 14:51:06 -04:00

42 lines
1.3 KiB
Python

""" add irb_info_event and irb_info_status tables
Revision ID: c1b37c418abd
Revises: 6c34576847ab
Create Date: 2021-06-17 12:40:05.411279
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c1b37c418abd'
down_revision = '6c34576847ab'
branch_labels = None
depends_on = None
def upgrade():
op.drop_column('irb_info', 'IRBEVENT')
op.create_table('irb_info_event',
sa.Column('STUDY_ID', sa.Integer(), nullable=False),
sa.Column('EVENT_ID', sa.String(), nullable=False, default=''),
sa.Column('EVENT', sa.String(), nullable=False, default=''),
sa.ForeignKeyConstraint(['STUDY_ID'], ['irb_info.SS_STUDY_ID'], ),
sa.PrimaryKeyConstraint('STUDY_ID'))
op.drop_column('irb_info', 'IRB_STATUS')
op.create_table('irb_info_status',
sa.Column('STUDY_ID', sa.Integer(), nullable=False),
sa.Column('STATUS_ID', sa.String(), nullable=False),
sa.Column('STATUS', sa.String(), nullable=False),
sa.ForeignKeyConstraint(('STUDY_ID',), ['irb_info.SS_STUDY_ID'], ),
sa.PrimaryKeyConstraint('STUDY_ID'))
def downgrade():
op.drop_table('irb_info_event')
op.add_column('irb_info', sa.Column('IRBEVENT', sa.String(), nullable=True, default=''))
op.drop_table('irb_info_status')
op.add_column('irb_info', sa.Column('IRB_STATUS', sa.String(), nullable=True, default=''))