"""Campaign history Revision ID: 67e604d86a08 Revises: 96687673c2bd Create Date: 2019-05-27 22:21:10.800333 """ from alembic import op import sqlalchemy as sa from migrations import utils from models.projects_history import ProjectHistoryAction # revision identifiers, used by Alembic. revision = '67e604d86a08' down_revision = '96687673c2bd' branch_labels = None depends_on = None class CampaignHistoryAction(ProjectHistoryAction): __tablename__ = "CampaignHistoryAction" def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'HistoryAction', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_HistoryAction')) ) op.create_table( 'HistoryUser', sa.Column('id', sa.String(), nullable=False), sa.Column('email', sa.String(), nullable=False), sa.Column('edit_date', sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_HistoryUser')) ) op.create_table( 'CampaignHistory', sa.Column('id', sa.BigInteger(), nullable=False), sa.Column('edit_date', sa.DateTime(), nullable=False), sa.Column('endpoint', sa.String(), nullable=False), sa.Column('parameters', sa.JSON(), nullable=False), sa.Column('campaign_id', sa.BigInteger(), nullable=False), sa.Column('history_action_id', sa.Integer(), nullable=False), sa.Column('history_user_id', sa.String(), nullable=False), sa.ForeignKeyConstraint( ['history_action_id'], ['HistoryAction.id'], name=op.f('fk_CampaignHistory_history_action_id_HistoryAction') ), sa.ForeignKeyConstraint( ['history_user_id'], ['HistoryUser.id'], name=op.f('fk_CampaignHistory_history_user_id_HistoryUser') ), sa.PrimaryKeyConstraint('id', name=op.f('pk_CampaignHistory')) ) bind = op.get_bind() session = sa.orm.Session(bind=bind) bind.execute(''' INSERT INTO "HistoryAction" VALUES (1, 'Insert'), (2, 'Update'), (3, 'Delete')''') session.commit() session.close() # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('CampaignHistory') op.drop_table('HistoryUser') op.drop_table('HistoryAction') # ### end Alembic commands ###