"""points added to user model; owner_id -> user_id; added state(announcement table)

Revision ID: 4e4d30fd58fc
Revises: 00529d20660b
Create Date: 2023-08-05 09:38:03.284306

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '4e4d30fd58fc'
down_revision = '00529d20660b'
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('user_id', sa.Integer(), nullable=True))
        # batch_op.drop_constraint(None, type_='foreignkey')
        batch_op.create_foreign_key('fk_users_id', 'users', ['user_id'], ['id'])
        batch_op.drop_column('owner_id')

    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.add_column(sa.Column('rating', sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column('reg_date', sa.Date(), 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('reg_date')
        batch_op.drop_column('rating')

    with op.batch_alter_table('announcements', schema=None) as batch_op:
        batch_op.add_column(sa.Column('owner_id', sa.INTEGER(), nullable=True))
        # batch_op.drop_constraint('fk_users_id', type_='foreignkey')
        batch_op.create_foreign_key(None, 'users', ['owner_id'], ['id'])
        batch_op.drop_column('user_id')

    # ### end Alembic commands ###
