"""add_qualification_protocol

Revision ID: b78571ae9e00
Revises: 70914b334cfb
Create Date: 2026-04-23 17:08:07.161306+00:00
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = 'b78571ae9e00'
down_revision: Union[str, None] = '70914b334cfb'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.execute("""
    CREATE TABLE IF NOT EXISTS qualification_protocols (
        id UUID PRIMARY KEY,
        name VARCHAR(128) NOT NULL,
        description TEXT,
        small_group_max INTEGER NOT NULL DEFAULT 5,
        collective_wot_min INTEGER NOT NULL DEFAULT 50,
        default_modalities_json TEXT NOT NULL DEFAULT '["vote_wot","vote_smith","consultation_avis","election"]',
        is_active BOOLEAN NOT NULL DEFAULT TRUE,
        created_at TIMESTAMPTZ DEFAULT now()
    )
    """)


def downgrade() -> None:
    op.drop_table('qualification_protocols')
