"""User model got a new field: num_of_ratings; delete name of ForeignKey; relationships changed

Revision ID: 9c19b9658512
Revises: 4e4d30fd58fc
Create Date: 2023-08-07 18:16:32.386940

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9c19b9658512'
down_revision = '4e4d30fd58fc'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('announcements', schema=None) as batch_op:
        batch_op.add_column(sa.Column('obsolete', sa.Boolean(), nullable=True))

    with op.batch_alter_table('poems', schema=None) as batch_op:
        batch_op.add_column(sa.Column('title', sa.String(), nullable=True))
        batch_op.add_column(sa.Column('text', sa.String(), nullable=True))
        batch_op.add_column(sa.Column('author', sa.String(), nullable=True))
        batch_op.drop_column('poem_text')
        batch_op.drop_column('poem_name')

    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.add_column(sa.Column('num_of_ratings', sa.Integer(), nullable=True))

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.drop_column('num_of_ratings')

    with op.batch_alter_table('poems', schema=None) as batch_op:
        batch_op.add_column(sa.Column('poem_name', sa.VARCHAR(), nullable=True))
        batch_op.add_column(sa.Column('poem_text', sa.VARCHAR(), nullable=True))
        batch_op.drop_column('author')
        batch_op.drop_column('text')
        batch_op.drop_column('title')

    with op.batch_alter_table('announcements', schema=None) as batch_op:
        batch_op.drop_column('obsolete')
    # ### end Alembic commands ###
