From 9dde839148e0bf15f96aba44c03bb8738caf756b Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Wed, 2 Dec 2020 14:25:46 +0100 Subject: [PATCH] Add migration for new database design --- web/migrations/versions/6c2227f1cc77_.py | 59 ++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 web/migrations/versions/6c2227f1cc77_.py diff --git a/web/migrations/versions/6c2227f1cc77_.py b/web/migrations/versions/6c2227f1cc77_.py new file mode 100644 index 00000000..9d58746e --- /dev/null +++ b/web/migrations/versions/6c2227f1cc77_.py @@ -0,0 +1,59 @@ +"""empty message + +Revision ID: 6c2227f1cc77 +Revises: befe5326787e +Create Date: 2020-12-02 08:50:45.880062 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '6c2227f1cc77' +down_revision = 'befe5326787e' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('notification_data') + op.drop_table('notification_email_data') + op.drop_column('corpus_files', 'dir') + op.drop_column('job_inputs', 'dir') + op.drop_column('job_results', 'dir') + op.drop_column('jobs', 'secure_filename') + op.alter_column('roles', 'permissions', + existing_type=sa.BIGINT(), + type_=sa.Integer(), + existing_nullable=True) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('roles', 'permissions', + existing_type=sa.Integer(), + type_=sa.BIGINT(), + existing_nullable=True) + op.add_column('jobs', sa.Column('secure_filename', sa.VARCHAR(length=32), autoincrement=False, nullable=True)) + op.add_column('job_results', sa.Column('dir', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) + op.add_column('job_inputs', sa.Column('dir', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) + op.add_column('corpus_files', sa.Column('dir', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) + op.create_table('notification_email_data', + sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column('job_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('notify_status', sa.VARCHAR(length=16), autoincrement=False, nullable=True), + sa.Column('creation_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.ForeignKeyConstraint(['job_id'], ['jobs.id'], name='notification_email_data_job_id_fkey'), + sa.PrimaryKeyConstraint('id', name='notification_email_data_pkey') + ) + op.create_table('notification_data', + sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column('job_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('notified_on', sa.VARCHAR(length=16), autoincrement=False, nullable=True), + sa.ForeignKeyConstraint(['job_id'], ['jobs.id'], name='notification_data_job_id_fkey'), + sa.PrimaryKeyConstraint('id', name='notification_data_pkey') + ) + # ### end Alembic commands ###