"""Create favorite table

Revision ID: afe1ef71bc36
Revises: 5d7b6f3d068e
Create Date: 2021-06-28 13:12:04.583439

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'afe1ef71bc36'
down_revision = '5d7b6f3d068e'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user_item',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('creation_date', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
    sa.Column('telegram_id', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('telegram_id')
    )
    op.create_table('favorite',
    sa.Column('ad_id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('creation_date', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
    sa.ForeignKeyConstraint(['ad_id'], ['ad.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user_item.id'], ),
    sa.PrimaryKeyConstraint('ad_id', 'user_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('favorite')
    op.drop_table('user_item')
    # ### end Alembic commands ###
