Nouvelle entité `Artist` (nom + jour de passage), CRUD
`/editions/{id}/artists` (lecture ouverte à tout compte de l'édition,
écriture COORDINATION), unicité (édition, nom, date).
La fiche bénévole porte deux listes de vœux, sur le modèle de
`skill_codes` (None = inchangé, [] = vider) :
- `artist_ids` : artistes que le bénévole veut voir (`volunteer_artist`) ;
- `wished_position_ids` : postes qu'il voudrait tenir
(`volunteer_position_wish`), distinct de l'affectation.
Un id étranger à l'édition renvoie 422 (`artist.unknown` /
`position.unknown`). Suppression d'un artiste : cascade sur les vœux.
Migration 0006. Jeu de démonstration et frontend inchangés (le front
suivra).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017uUsRg7XzopkCPWimwg9ZM
81 lines
2.6 KiB
Python
81 lines
2.6 KiB
Python
"""Artiste (programmation) + vœux des bénévoles (artistes, postes)
|
|
|
|
Revision ID: 0006_artist_and_volunteer_wishes
|
|
Revises: 0005_drop_volunteer_tshirt_diet
|
|
Create Date: 2026-09-10
|
|
|
|
"""
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "0006_artist_and_volunteer_wishes"
|
|
down_revision: str | None = "0005_drop_volunteer_tshirt_diet"
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"artist",
|
|
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
|
sa.Column("id", sa.Uuid(), nullable=False),
|
|
sa.Column("edition_id", sa.Uuid(), nullable=False),
|
|
sa.Column("name", sa.String(), nullable=False),
|
|
sa.Column("performance_date", sa.Date(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["edition_id"], ["edition.id"], ondelete="CASCADE"
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint(
|
|
"edition_id", "name", "performance_date",
|
|
name="uq_artist_edition_name_date",
|
|
),
|
|
)
|
|
op.create_index(
|
|
op.f("ix_artist_edition_id"), "artist", ["edition_id"], unique=False
|
|
)
|
|
op.create_index(
|
|
op.f("ix_artist_performance_date"),
|
|
"artist",
|
|
["performance_date"],
|
|
unique=False,
|
|
)
|
|
|
|
op.create_table(
|
|
"volunteer_artist",
|
|
sa.Column("volunteer_id", sa.Uuid(), nullable=False),
|
|
sa.Column("artist_id", sa.Uuid(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["artist_id"], ["artist.id"], ondelete="CASCADE"
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["volunteer_id"], ["volunteer.id"], ondelete="CASCADE"
|
|
),
|
|
sa.PrimaryKeyConstraint("volunteer_id", "artist_id"),
|
|
)
|
|
|
|
op.create_table(
|
|
"volunteer_position_wish",
|
|
sa.Column("volunteer_id", sa.Uuid(), nullable=False),
|
|
sa.Column("position_id", sa.Uuid(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["position_id"], ["position.id"], ondelete="CASCADE"
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["volunteer_id"], ["volunteer.id"], ondelete="CASCADE"
|
|
),
|
|
sa.PrimaryKeyConstraint("volunteer_id", "position_id"),
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table("volunteer_position_wish")
|
|
op.drop_table("volunteer_artist")
|
|
op.drop_index(op.f("ix_artist_performance_date"), table_name="artist")
|
|
op.drop_index(op.f("ix_artist_edition_id"), table_name="artist")
|
|
op.drop_table("artist")
|