"""Vœu de bénévole : être affecté avec tel(s) autre(s) bénévole(s) Revision ID: 0010_companion_wish Revises: 0009_volunteer_email_not_unique Create Date: 2026-09-15 Table `volunteer_companion_wish` : de 0 à N vœux par bénévole, à sens unique (A peut souhaiter B sans que B ne le souhaite en retour). Le solveur (section 4 de CLAUDE.md) favorise un candidat dont l'un des compagnons souhaités est déjà affecté au créneau. """ from collections.abc import Sequence import sqlalchemy as sa from alembic import op revision: str = "0010_companion_wish" down_revision: str | None = "0009_volunteer_email_not_unique" branch_labels: str | Sequence[str] | None = None depends_on: str | Sequence[str] | None = None def upgrade() -> None: op.create_table( "volunteer_companion_wish", sa.Column("volunteer_id", sa.Uuid(), nullable=False), sa.Column("companion_id", sa.Uuid(), nullable=False), sa.CheckConstraint( "volunteer_id <> companion_id", name="ck_companion_wish_not_self" ), sa.ForeignKeyConstraint(["companion_id"], ["volunteer.id"], ondelete="CASCADE"), sa.ForeignKeyConstraint(["volunteer_id"], ["volunteer.id"], ondelete="CASCADE"), sa.PrimaryKeyConstraint("volunteer_id", "companion_id"), ) def downgrade() -> None: op.drop_table("volunteer_companion_wish")