"""Formulaire public d'inscription + champs bénévole associés Revision ID: 0013_signup_form Revises: 0012_badge_template_size Create Date: 2026-09-21 Deux tables : `form_template` (configuration par édition — ouvert/fermé) et `form_field` (champs activés, présence = activation). Sur `volunteer` : `photo`/`photo_content_type` (formulaire public), `companion_wish_note` (vœu de compagnon en texte libre, résolu ensuite par la coordination), `self_declared_available`/`willing_to_pay_fee` (cases à cocher purement informatives). Voir `app/api/forms.py`. """ from collections.abc import Sequence import sqlalchemy as sa from alembic import op revision: str = "0013_signup_form" down_revision: str | None = "0012_badge_template_size" branch_labels: str | Sequence[str] | None = None depends_on: str | Sequence[str] | None = None def upgrade() -> None: op.add_column("volunteer", sa.Column("photo", sa.LargeBinary(), nullable=True)) op.add_column( "volunteer", sa.Column("photo_content_type", sa.String(), nullable=True) ) op.add_column( "volunteer", sa.Column("companion_wish_note", sa.String(), nullable=True) ) op.add_column( "volunteer", sa.Column( "self_declared_available", sa.Boolean(), server_default="false", nullable=False, ), ) op.add_column( "volunteer", sa.Column( "willing_to_pay_fee", sa.Boolean(), server_default="false", nullable=False, ), ) op.create_table( "form_template", sa.Column("id", sa.Uuid(), nullable=False), sa.Column("edition_id", sa.Uuid(), nullable=False), sa.Column( "is_open", sa.Boolean(), server_default="true", nullable=False ), sa.Column("created_at", sa.DateTime(), nullable=False), sa.Column("updated_at", sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(["edition_id"], ["edition.id"], ondelete="CASCADE"), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("edition_id"), ) op.create_table( "form_field", sa.Column("id", sa.Uuid(), nullable=False), sa.Column("edition_id", sa.Uuid(), nullable=False), sa.Column( "field_type", sa.Enum( "EMAIL", "PHONE", "POSITION_WISHES", "ARTIST_WISHES", "COMPANION_WISH", "AVAILABLE", "WILLING_TO_PAY_FEE", "PHOTO", "COMMENT", name="formfieldtype", native_enum=False, ), nullable=False, ), sa.ForeignKeyConstraint(["edition_id"], ["edition.id"], ondelete="CASCADE"), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint( "edition_id", "field_type", name="uq_form_field_edition_type" ), ) op.create_index("ix_form_field_edition_id", "form_field", ["edition_id"]) def downgrade() -> None: op.drop_index("ix_form_field_edition_id", table_name="form_field") op.drop_table("form_field") op.drop_table("form_template") op.drop_column("volunteer", "willing_to_pay_fee") op.drop_column("volunteer", "self_declared_available") op.drop_column("volunteer", "companion_wish_note") op.drop_column("volunteer", "photo_content_type") op.drop_column("volunteer", "photo")