<reponame>havanhuy1997/pmg-cms-2<filename>migrations/versions/bb8e91317dc_sync.py
"""sync

Revision ID: bb8e91317dc
Revises: 2<PASSWORD>6e35<PASSWORD>
Create Date: 2015-10-07 08:47:01.661978

"""

# revision identifiers, used by Alembic.
revision = 'bb8e91317dc'
down_revision = '292886e35ea7'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('date_code_ix', table_name='committee_question')
    op.create_unique_constraint('date_code_ix', 'committee_question', ['date', 'code'])
    op.drop_index('date_deputy_president_number_ix', table_name='committee_question')
    op.create_unique_constraint('date_deputy_president_number_ix', 'committee_question', ['date', 'house_id', 'deputy_president_number'])
    op.drop_index('date_oral_number_ix', table_name='committee_question')
    op.create_unique_constraint('date_oral_number_ix', 'committee_question', ['date', 'house_id', 'oral_number'])
    op.drop_index('date_president_number_ix', table_name='committee_question')
    op.create_unique_constraint('date_president_number_ix', 'committee_question', ['date', 'house_id', 'president_number'])
    op.drop_index('date_written_number_ix', table_name='committee_question')
    op.create_unique_constraint('date_written_number_ix', 'committee_question', ['date', 'house_id', 'written_number'])
    op.drop_constraint(u'committee_question_minister_id_fkey', 'committee_question', type_='foreignkey')
    op.create_foreign_key(None, 'committee_question', 'minister', ['minister_id'], ['id'], ondelete='SET NULL')
    op.drop_constraint(u'daily_schedule_file_join_file_id_fkey', 'daily_schedule_file_join', type_='foreignkey')
    op.drop_constraint(u'daily_schedule_file_join_daily_schedule_id_fkey', 'daily_schedule_file_join', type_='foreignkey')
    op.create_foreign_key(None, 'daily_schedule_file_join', 'daily_schedule', ['daily_schedule_id'], ['id'], ondelete='CASCADE')
    op.create_foreign_key(None, 'daily_schedule_file_join', 'file', ['file_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'gazette_file_join_gazette_id_fkey', 'gazette_file_join', type_='foreignkey')
    op.drop_constraint(u'gazette_file_join_file_id_fkey', 'gazette_file_join', type_='foreignkey')
    op.create_foreign_key(None, 'gazette_file_join', 'file', ['file_id'], ['id'], ondelete='CASCADE')
    op.create_foreign_key(None, 'gazette_file_join', 'gazette', ['gazette_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'policy_document_file_join_policy_document_id_fkey', 'policy_document_file_join', type_='foreignkey')
    op.drop_constraint(u'policy_document_file_join_file_id_fkey', 'policy_document_file_join', type_='foreignkey')
    op.create_foreign_key(None, 'policy_document_file_join', 'file', ['file_id'], ['id'], ondelete='CASCADE')
    op.create_foreign_key(None, 'policy_document_file_join', 'policy_document', ['policy_document_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'question_reply_minister_id_fkey', 'question_reply', type_='foreignkey')
    op.create_foreign_key(None, 'question_reply', 'minister', ['minister_id'], ['id'], ondelete='SET NULL')
    op.drop_constraint(u'tabled_committee_report_file_join_file_id_fkey', 'tabled_committee_report_file_join', type_='foreignkey')
    op.drop_constraint(u'tabled_committee_report_file_jo_tabled_committee_report_id_fkey', 'tabled_committee_report_file_join', type_='foreignkey')
    op.create_foreign_key(None, 'tabled_committee_report_file_join', 'file', ['file_id'], ['id'], ondelete='CASCADE')
    op.create_foreign_key(None, 'tabled_committee_report_file_join', 'tabled_committee_report', ['tabled_committee_report_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'user_email_key', 'user', type_='unique')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint(u'user_email_key', 'user', ['email'])
    op.drop_constraint(None, 'tabled_committee_report_file_join', type_='foreignkey')
    op.drop_constraint(None, 'tabled_committee_report_file_join', type_='foreignkey')
    op.create_foreign_key(u'tabled_committee_report_file_jo_tabled_committee_report_id_fkey', 'tabled_committee_report_file_join', 'tabled_committee_report', ['tabled_committee_report_id'], ['id'])
    op.create_foreign_key(u'tabled_committee_report_file_join_file_id_fkey', 'tabled_committee_report_file_join', 'file', ['file_id'], ['id'])
    op.drop_constraint(None, 'question_reply', type_='foreignkey')
    op.create_foreign_key(u'question_reply_minister_id_fkey', 'question_reply', 'minister', ['minister_id'], ['id'])
    op.drop_constraint(None, 'policy_document_file_join', type_='foreignkey')
    op.drop_constraint(None, 'policy_document_file_join', type_='foreignkey')
    op.create_foreign_key(u'policy_document_file_join_file_id_fkey', 'policy_document_file_join', 'file', ['file_id'], ['id'])
    op.create_foreign_key(u'policy_document_file_join_policy_document_id_fkey', 'policy_document_file_join', 'policy_document', ['policy_document_id'], ['id'])
    op.drop_constraint(None, 'gazette_file_join', type_='foreignkey')
    op.drop_constraint(None, 'gazette_file_join', type_='foreignkey')
    op.create_foreign_key(u'gazette_file_join_file_id_fkey', 'gazette_file_join', 'file', ['file_id'], ['id'])
    op.create_foreign_key(u'gazette_file_join_gazette_id_fkey', 'gazette_file_join', 'gazette', ['gazette_id'], ['id'])
    op.drop_constraint(None, 'daily_schedule_file_join', type_='foreignkey')
    op.drop_constraint(None, 'daily_schedule_file_join', type_='foreignkey')
    op.create_foreign_key(u'daily_schedule_file_join_daily_schedule_id_fkey', 'daily_schedule_file_join', 'daily_schedule', ['daily_schedule_id'], ['id'])
    op.create_foreign_key(u'daily_schedule_file_join_file_id_fkey', 'daily_schedule_file_join', 'file', ['file_id'], ['id'])
    op.drop_constraint(None, 'committee_question', type_='foreignkey')
    op.create_foreign_key(u'committee_question_minister_id_fkey', 'committee_question', 'minister', ['minister_id'], ['id'])
    op.drop_constraint('date_written_number_ix', 'committee_question', type_='unique')
    op.create_index('date_written_number_ix', 'committee_question', ['date', 'house_id', 'written_number'], unique=True)
    op.drop_constraint('date_president_number_ix', 'committee_question', type_='unique')
    op.create_index('date_president_number_ix', 'committee_question', ['date', 'house_id', 'president_number'], unique=True)
    op.drop_constraint('date_oral_number_ix', 'committee_question', type_='unique')
    op.create_index('date_oral_number_ix', 'committee_question', ['date', 'house_id', 'oral_number'], unique=True)
    op.drop_constraint('date_deputy_president_number_ix', 'committee_question', type_='unique')
    op.create_index('date_deputy_president_number_ix', 'committee_question', ['date', 'house_id', 'deputy_president_number'], unique=True)
    op.drop_constraint('date_code_ix', 'committee_question', type_='unique')
    op.create_index('date_code_ix', 'committee_question', ['date', 'code'], unique=True)
    ### end Alembic commands ###

"""sync

Revision ID: bb8e91317dc
Revises: 2<PASSWORD>6e35<PASSWORD>
Create Date: 2015-10-07 08:47:01.661978

"""

# revision identifiers, used by Alembic.
revision = 'bb8e91317dc'
down_revision = '292886e35ea7'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('date_code_ix', table_name='committee_question')
    op.create_unique_constraint('date_code_ix', 'committee_question', ['date', 'code'])
    op.drop_index('date_deputy_president_number_ix', table_name='committee_question')
    op.create_unique_constraint('date_deputy_president_number_ix', 'committee_question', ['date', 'house_id', 'deputy_president_number'])
    op.drop_index('date_oral_number_ix', table_name='committee_question')
    op.create_unique_constraint('date_oral_number_ix', 'committee_question', ['date', 'house_id', 'oral_number'])
    op.drop_index('date_president_number_ix', table_name='committee_question')
    op.create_unique_constraint('date_president_number_ix', 'committee_question', ['date', 'house_id', 'president_number'])
    op.drop_index('date_written_number_ix', table_name='committee_question')
    op.create_unique_constraint('date_written_number_ix', 'committee_question', ['date', 'house_id', 'written_number'])
    op.drop_constraint(u'committee_question_minister_id_fkey', 'committee_question', type_='foreignkey')
    op.create_foreign_key(None, 'committee_question', 'minister', ['minister_id'], ['id'], ondelete='SET NULL')
    op.drop_constraint(u'daily_schedule_file_join_file_id_fkey', 'daily_schedule_file_join', type_='foreignkey')
    op.drop_constraint(u'daily_schedule_file_join_daily_schedule_id_fkey', 'daily_schedule_file_join', type_='foreignkey')
    op.create_foreign_key(None, 'daily_schedule_file_join', 'daily_schedule', ['daily_schedule_id'], ['id'], ondelete='CASCADE')
    op.create_foreign_key(None, 'daily_schedule_file_join', 'file', ['file_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'gazette_file_join_gazette_id_fkey', 'gazette_file_join', type_='foreignkey')
    op.drop_constraint(u'gazette_file_join_file_id_fkey', 'gazette_file_join', type_='foreignkey')
    op.create_foreign_key(None, 'gazette_file_join', 'file', ['file_id'], ['id'], ondelete='CASCADE')
    op.create_foreign_key(None, 'gazette_file_join', 'gazette', ['gazette_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'policy_document_file_join_policy_document_id_fkey', 'policy_document_file_join', type_='foreignkey')
    op.drop_constraint(u'policy_document_file_join_file_id_fkey', 'policy_document_file_join', type_='foreignkey')
    op.create_foreign_key(None, 'policy_document_file_join', 'file', ['file_id'], ['id'], ondelete='CASCADE')
    op.create_foreign_key(None, 'policy_document_file_join', 'policy_document', ['policy_document_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'question_reply_minister_id_fkey', 'question_reply', type_='foreignkey')
    op.create_foreign_key(None, 'question_reply', 'minister', ['minister_id'], ['id'], ondelete='SET NULL')
    op.drop_constraint(u'tabled_committee_report_file_join_file_id_fkey', 'tabled_committee_report_file_join', type_='foreignkey')
    op.drop_constraint(u'tabled_committee_report_file_jo_tabled_committee_report_id_fkey', 'tabled_committee_report_file_join', type_='foreignkey')
    op.create_foreign_key(None, 'tabled_committee_report_file_join', 'file', ['file_id'], ['id'], ondelete='CASCADE')
    op.create_foreign_key(None, 'tabled_committee_report_file_join', 'tabled_committee_report', ['tabled_committee_report_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'user_email_key', 'user', type_='unique')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint(u'user_email_key', 'user', ['email'])
    op.drop_constraint(None, 'tabled_committee_report_file_join', type_='foreignkey')
    op.drop_constraint(None, 'tabled_committee_report_file_join', type_='foreignkey')
    op.create_foreign_key(u'tabled_committee_report_file_jo_tabled_committee_report_id_fkey', 'tabled_committee_report_file_join', 'tabled_committee_report', ['tabled_committee_report_id'], ['id'])
    op.create_foreign_key(u'tabled_committee_report_file_join_file_id_fkey', 'tabled_committee_report_file_join', 'file', ['file_id'], ['id'])
    op.drop_constraint(None, 'question_reply', type_='foreignkey')
    op.create_foreign_key(u'question_reply_minister_id_fkey', 'question_reply', 'minister', ['minister_id'], ['id'])
    op.drop_constraint(None, 'policy_document_file_join', type_='foreignkey')
    op.drop_constraint(None, 'policy_document_file_join', type_='foreignkey')
    op.create_foreign_key(u'policy_document_file_join_file_id_fkey', 'policy_document_file_join', 'file', ['file_id'], ['id'])
    op.create_foreign_key(u'policy_document_file_join_policy_document_id_fkey', 'policy_document_file_join', 'policy_document', ['policy_document_id'], ['id'])
    op.drop_constraint(None, 'gazette_file_join', type_='foreignkey')
    op.drop_constraint(None, 'gazette_file_join', type_='foreignkey')
    op.create_foreign_key(u'gazette_file_join_file_id_fkey', 'gazette_file_join', 'file', ['file_id'], ['id'])
    op.create_foreign_key(u'gazette_file_join_gazette_id_fkey', 'gazette_file_join', 'gazette', ['gazette_id'], ['id'])
    op.drop_constraint(None, 'daily_schedule_file_join', type_='foreignkey')
    op.drop_constraint(None, 'daily_schedule_file_join', type_='foreignkey')
    op.create_foreign_key(u'daily_schedule_file_join_daily_schedule_id_fkey', 'daily_schedule_file_join', 'daily_schedule', ['daily_schedule_id'], ['id'])
    op.create_foreign_key(u'daily_schedule_file_join_file_id_fkey', 'daily_schedule_file_join', 'file', ['file_id'], ['id'])
    op.drop_constraint(None, 'committee_question', type_='foreignkey')
    op.create_foreign_key(u'committee_question_minister_id_fkey', 'committee_question', 'minister', ['minister_id'], ['id'])
    op.drop_constraint('date_written_number_ix', 'committee_question', type_='unique')
    op.create_index('date_written_number_ix', 'committee_question', ['date', 'house_id', 'written_number'], unique=True)
    op.drop_constraint('date_president_number_ix', 'committee_question', type_='unique')
    op.create_index('date_president_number_ix', 'committee_question', ['date', 'house_id', 'president_number'], unique=True)
    op.drop_constraint('date_oral_number_ix', 'committee_question', type_='unique')
    op.create_index('date_oral_number_ix', 'committee_question', ['date', 'house_id', 'oral_number'], unique=True)
    op.drop_constraint('date_deputy_president_number_ix', 'committee_question', type_='unique')
    op.create_index('date_deputy_president_number_ix', 'committee_question', ['date', 'house_id', 'deputy_president_number'], unique=True)
    op.drop_constraint('date_code_ix', 'committee_question', type_='unique')
    op.create_index('date_code_ix', 'committee_question', ['date', 'code'], unique=True)
    ### end Alembic commands ###
sync  Revision ID: bb8e91317dc Revises: 2<PASSWORD>6e35<PASSWORD> Create Date: 2015-10-07 08:47:01.661978 # revision identifiers, used by Alembic. ### commands auto generated by Alembic - please adjust! ### ### end Alembic commands ### ### commands auto generated by Alembic - please adjust! ### ### end Alembic commands ###