"""Renaming submission_narrative table to comment

Revision ID: f538dc9dc328
Revises: e9c556a9f344
Create Date: 2019-09-16 11:09:43.188509

"""

# revision identifiers, used by Alembic.
revision = 'f538dc9dc328'
down_revision = 'e9c556a9f344'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

def upgrade(engine_name):
    globals()["upgrade_%s" % engine_name]()


def downgrade(engine_name):
    globals()["downgrade_%s" % engine_name]()





def upgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute('ALTER TABLE submission_narrative RENAME TO comment')
    op.execute('ALTER TABLE comment RENAME COLUMN submission_narrative_id TO comment_id')
    op.execute('ALTER TABLE comment RENAME COLUMN narrative TO comment')
    op.execute('ALTER INDEX submission_narrative_pkey RENAME TO comment_pkey')
    op.execute('ALTER SEQUENCE submission_narrative_submission_narrative_id_seq RENAME TO comment_comment_id_seq')
    op.execute('ALTER TABLE certified_files_history RENAME COLUMN narrative TO comment')
    # ### end Alembic commands ###


def downgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute('ALTER TABLE comment RENAME TO submission_narrative')
    op.execute('ALTER TABLE submission_narrative RENAME COLUMN comment_id TO submission_narrative_id')
    op.execute('ALTER TABLE submission_narrative RENAME COLUMN comment TO narrative')
    op.execute('ALTER INDEX comment_pkey RENAME TO submission_narrative_pkey')
    op.execute('ALTER SEQUENCE comment_comment_id_seq RENAME TO submission_narrative_submission_narrative_id_seq')
    op.execute('ALTER TABLE certified_files_history RENAME COLUMN comment TO narrative')
    # ### end Alembic commands ###

