"""Rule models

Revision ID: 236434afb81a
Revises: 2e90b8948231
Create Date: 2015-01-14 16:29:19.407878

"""

# revision identifiers, used by Alembic.
revision = '236434afb81a'
down_revision = '2e90b8948231'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('rule',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('meeting_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['meeting_id'], ['meeting.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('condition',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('rule_id', sa.Integer(), nullable=True),
    sa.Column('field_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['field_id'], ['custom_field.id'], ),
    sa.ForeignKeyConstraint(['rule_id'], ['rule.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('action',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('rule_id', sa.Integer(), nullable=True),
    sa.Column('action_type', sa.Unicode(length=255), nullable=False),
    sa.Column('field_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['field_id'], ['custom_field.id'], ),
    sa.ForeignKeyConstraint(['rule_id'], ['rule.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('condition_value',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('condition_id', sa.Integer(), nullable=True),
    sa.Column('value', sa.String(length=255), nullable=False),
    sa.ForeignKeyConstraint(['condition_id'], ['condition.id'],
                            ondelete="CASCADE"),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('condition_value')
    op.drop_table('action')
    op.drop_table('condition')
    op.drop_table('rule')
    ### end Alembic commands ###
