"""timestamps

Revision ID: 4b751cb703e2
Revises: 3b8b8a5b99ad
Create Date: 2025-05-13 13:26:42.259154

"""
from datetime import datetime

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '4b751cb703e2'
down_revision = '3b8b8a5b99ad'
branch_labels = None
depends_on = None


def upgrade():
    op.add_column('server', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('server', sa.Column('updated_at', sa.DateTime(), nullable=True))

    current_time = f"timestamp '{datetime.now().isoformat()}'"
    op.execute(f"""UPDATE server SET created_at = {current_time}, updated_at = {current_time}""")
    op.alter_column("server", "created_at", nullable=False)
    op.alter_column("server", "updated_at", nullable=False)


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('server', 'updated_at')
    op.drop_column('server', 'created_at')
    # ### end Alembic commands ###
