# Database

The MySQL schema is exported in `docs/schema.sql` and wrapped by the Yii 3 migration `M260502174800CreateCoreSchema`.

## Highlights

- Configurable RBAC: `roles`, `permissions`, `role_permissions`, `user_roles`.
- Organiser scoping: `organiser_staff`, nullable organiser/event scope columns on `user_roles`.
- Organiser module policy gates: `organiser_features` stores global defaults and `organiser_feature_overrides` stores per-organiser exceptions.
- Event inventory: reusable venue maps in `venue_seat_maps` and event-specific state in `event_seats`.
- Checkout safety: `seat_holds`, `orders`, `order_items`, `tickets`, `payments`, `payment_transactions`.
- Accounting clarity: order columns and `tax_breakdowns` keep ticket, tax, platform fee, organiser revenue, donation, merchandise, and Stripe fee components separate.
- Operations: products, promo codes, donations, scanner devices, scan logs, attendee imports.
- Media lifecycle: `media_assets` stores upload metadata, soft-delete state, alt text, crop metadata, and `event_media` links assets into poster, hero, ticket background, and gallery slots.
- Compliance: user consents, privacy requests, audit logs, delivery logs, settings, webhooks.

Use UUID-like `CHAR(32)` identifiers for local simplicity. A production deployment should standardise ID generation and avoid exposing internal IDs in public APIs.
