"""notifications

Revision ID: cae2e31293e8
Revises: ee45b9ea4a0c
Create Date: 2023-11-30 22:49:24.942158

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'cae2e31293e8'
down_revision = 'ee45b9ea4a0c'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('notification',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=50), nullable=True),
    sa.Column('url', sa.String(length=512), nullable=True),
    sa.Column('read', sa.Boolean(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('post', schema=None) as batch_op:
        batch_op.add_column(sa.Column('notify_author', sa.Boolean(), nullable=True))

    with op.batch_alter_table('post_reply', schema=None) as batch_op:
        batch_op.add_column(sa.Column('notify_author', sa.Boolean(), nullable=True))

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

    # ### end Alembic commands ###


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

    with op.batch_alter_table('post_reply', schema=None) as batch_op:
        batch_op.drop_column('notify_author')

    with op.batch_alter_table('post', schema=None) as batch_op:
        batch_op.drop_column('notify_author')

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