"""ForeignKey added to Announcement model

Revision ID: 00529d20660b
Revises: 
Create Date: 2023-07-30 12:24:13.714196

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '00529d20660b'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('poems',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('poem_name', sa.String(), nullable=True),
    sa.Column('poem_text', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('poems', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_poems_id'), ['id'], unique=False)

    op.create_table('trashboxes',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('address', sa.String(), nullable=True),
    sa.Column('latitude', sa.Integer(), nullable=True),
    sa.Column('longtitude', sa.Integer(), nullable=True),
    sa.Column('category', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('trashboxes', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_trashboxes_id'), ['id'], unique=False)

    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(), nullable=True),
    sa.Column('hashed_password', sa.String(), nullable=True),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('surname', sa.String(), nullable=True),
    sa.Column('disabled', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_users_id'), ['id'], unique=True)

    op.create_table('announcements',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('owner_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('category', sa.String(), nullable=True),
    sa.Column('best_by', sa.Date(), nullable=True),
    sa.Column('address', sa.String(), nullable=True),
    sa.Column('longtitude', sa.Integer(), nullable=True),
    sa.Column('latitude', sa.Integer(), nullable=True),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('src', sa.String(), nullable=True),
    sa.Column('metro', sa.String(), nullable=True),
    sa.Column('trashId', sa.Integer(), nullable=True),
    sa.Column('booked_by', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['owner_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('announcements', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_announcements_id'), ['id'], unique=False)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('announcements', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_announcements_id'))

    op.drop_table('announcements')
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_users_id'))

    op.drop_table('users')
    with op.batch_alter_table('trashboxes', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_trashboxes_id'))

    op.drop_table('trashboxes')
    with op.batch_alter_table('poems', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_poems_id'))

    op.drop_table('poems')
    # ### end Alembic commands ###
