This migration will clear out any approvals in the database.

This commit is contained in:
Dan Funk 2020-05-28 20:13:33 -04:00
parent aea78de066
commit 22bdb6c760
1 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,63 @@
"""empty message
Revision ID: bec71f7dc652
Revises: 23c62c933848
Create Date: 2020-05-28 20:08:45.891406
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = 'bec71f7dc652'
down_revision = '23c62c933848'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('workflow_spec_dependency_file',
sa.Column('file_data_id', sa.Integer(), nullable=False),
sa.Column('workflow_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['file_data_id'], ['file_data.id'], ),
sa.ForeignKeyConstraint(['workflow_id'], ['workflow.id'], ),
sa.PrimaryKeyConstraint('file_data_id', 'workflow_id')
)
op.drop_column('approval', 'workflow_hash')
op.execute(
"""
delete from approval_file;
delete from approval;
"""
)
op.add_column('approval_file', sa.Column('file_data_id', sa.Integer(), nullable=False))
op.drop_constraint('approval_file_file_id_fkey', 'approval_file', type_='foreignkey')
op.create_foreign_key(None, 'approval_file', 'file_data', ['file_data_id'], ['id'])
op.drop_column('approval_file', 'id')
op.drop_column('approval_file', 'file_version')
op.drop_column('approval_file', 'file_id')
op.drop_column('file', 'latest_version')
op.add_column('file_data', sa.Column('date_created', sa.DateTime(timezone=True), nullable=True))
op.drop_column('file_data', 'last_updated')
op.drop_column('workflow', 'spec_version')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('workflow', sa.Column('spec_version', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('file_data', sa.Column('last_updated', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
op.drop_column('file_data', 'date_created')
op.add_column('file', sa.Column('latest_version', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('approval_file', sa.Column('file_id', sa.INTEGER(), autoincrement=False, nullable=False))
op.add_column('approval_file', sa.Column('file_version', sa.INTEGER(), autoincrement=False, nullable=False))
op.add_column('approval_file', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False))
op.drop_constraint(None, 'approval_file', type_='foreignkey')
op.create_foreign_key('approval_file_file_id_fkey', 'approval_file', 'file', ['file_id'], ['id'])
op.drop_column('approval_file', 'file_data_id')
op.add_column('approval', sa.Column('workflow_hash', sa.VARCHAR(), autoincrement=False, nullable=True))
op.drop_table('workflow_spec_dependency_file')
# ### end Alembic commands ###