"""public stamp token + opt-in flag for static QR stamping

Revision ID: 0033
Revises: 0032
Create Date: 2026-06-02
"""
from alembic import op
import sqlalchemy as sa

revision = '0033'
down_revision = '0032'
branch_labels = None
depends_on = None


def upgrade():
    op.add_column(
        'companies',
        sa.Column('public_stamp_enabled', sa.Boolean(), nullable=False, server_default=sa.false()),
    )
    op.add_column(
        'companies',
        sa.Column('public_stamp_token_hash', sa.String(length=64), nullable=True),
    )
    op.add_column(
        'companies',
        sa.Column('public_stamp_token_created_at', sa.DateTime(timezone=True), nullable=True),
    )
    op.create_unique_constraint(
        'uq_companies_public_stamp_token_hash', 'companies', ['public_stamp_token_hash']
    )


def downgrade():
    op.drop_constraint('uq_companies_public_stamp_token_hash', 'companies', type_='unique')
    op.drop_column('companies', 'public_stamp_token_created_at')
    op.drop_column('companies', 'public_stamp_token_hash')
    op.drop_column('companies', 'public_stamp_enabled')
