/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `activity_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `activity_log` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `log_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `subject_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `subject_id` varchar(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `causer_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `causer_id` varchar(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `attribute_changes` json DEFAULT NULL,
  `properties` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `subject` (`subject_type`,`subject_id`),
  KEY `causer` (`causer_type`,`causer_id`),
  KEY `activity_log_log_name_index` (`log_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `advance_sections`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `advance_sections` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `engagement_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_open` tinyint(1) NOT NULL DEFAULT '0',
  `open_from` datetime DEFAULT NULL,
  `open_to` datetime DEFAULT NULL,
  `sort_order` int NOT NULL DEFAULT '0',
  `submission_status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',
  `last_submitted_at` timestamp NULL DEFAULT NULL,
  `last_submitted_by` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `submission_diff` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `advance_sections_engagement_id_is_open_index` (`engagement_id`,`is_open`),
  KEY `advance_sections_engagement_id_submission_status_index` (`engagement_id`,`submission_status`),
  CONSTRAINT `advance_sections_engagement_id_foreign` FOREIGN KEY (`engagement_id`) REFERENCES `artist_engagements` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `advance_submissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `advance_submissions` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `advance_section_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `submitted_by_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `submitted_by_email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `submitted_at` timestamp NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `reviewed_by` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reviewed_at` timestamp NULL DEFAULT NULL,
  `data` json NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `advance_submissions_reviewed_by_foreign` (`reviewed_by`),
  KEY `advance_submissions_advance_section_id_status_index` (`advance_section_id`,`status`),
  CONSTRAINT `advance_submissions_advance_section_id_foreign` FOREIGN KEY (`advance_section_id`) REFERENCES `advance_sections` (`id`) ON DELETE CASCADE,
  CONSTRAINT `advance_submissions_reviewed_by_foreign` FOREIGN KEY (`reviewed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `artist_contacts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `artist_contacts` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `artist_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `role` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_primary` tinyint(1) NOT NULL DEFAULT '0',
  `receives_briefing` tinyint(1) NOT NULL DEFAULT '0',
  `receives_infosheet` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `artist_contacts_artist_id_role_index` (`artist_id`,`role`),
  CONSTRAINT `artist_contacts_artist_id_foreign` FOREIGN KEY (`artist_id`) REFERENCES `artists` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `artist_engagements`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `artist_engagements` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `artist_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `booking_status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `project_leader_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fee_amount` decimal(10,2) DEFAULT NULL,
  `fee_currency` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'EUR',
  `fee_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `buma_applicable` tinyint(1) NOT NULL DEFAULT '1',
  `buma_percentage` decimal(5,2) NOT NULL DEFAULT '7.00',
  `buma_handled_by` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'organisation',
  `vat_applicable` tinyint(1) NOT NULL DEFAULT '1',
  `vat_percentage` decimal(5,2) NOT NULL DEFAULT '21.00',
  `deal_breakdown` json DEFAULT NULL,
  `deposit_percentage` decimal(5,2) DEFAULT NULL,
  `deposit_due_date` date DEFAULT NULL,
  `balance_due_date` date DEFAULT NULL,
  `payment_status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'none',
  `crew_count` int NOT NULL DEFAULT '0',
  `guests_count` int NOT NULL DEFAULT '0',
  `requested_at` datetime DEFAULT NULL,
  `option_expires_at` datetime DEFAULT NULL,
  `advance_open_from` datetime DEFAULT NULL,
  `advance_open_to` datetime DEFAULT NULL,
  `portal_token` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `advancing_completed_count` int NOT NULL DEFAULT '0',
  `advancing_total_count` int NOT NULL DEFAULT '0',
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `artist_engagements_artist_id_event_id_unique` (`artist_id`,`event_id`),
  UNIQUE KEY `artist_engagements_portal_token_unique` (`portal_token`),
  KEY `artist_engagements_project_leader_id_foreign` (`project_leader_id`),
  KEY `artist_engagements_organisation_id_index` (`organisation_id`),
  KEY `artist_engagements_event_id_booking_status_index` (`event_id`,`booking_status`),
  KEY `artist_engagements_option_expires_at_index` (`option_expires_at`),
  CONSTRAINT `artist_engagements_artist_id_foreign` FOREIGN KEY (`artist_id`) REFERENCES `artists` (`id`) ON DELETE CASCADE,
  CONSTRAINT `artist_engagements_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `artist_engagements_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE,
  CONSTRAINT `artist_engagements_project_leader_id_foreign` FOREIGN KEY (`project_leader_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `artists`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `artists` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `default_genre_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `default_draw` int DEFAULT NULL,
  `star_rating` tinyint DEFAULT NULL,
  `home_base_country` varchar(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `agent_company_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `artists_organisation_id_slug_unique` (`organisation_id`,`slug`),
  KEY `artists_organisation_id_name_index` (`organisation_id`,`name`),
  KEY `artists_default_genre_id_index` (`default_genre_id`),
  KEY `artists_agent_company_id_index` (`agent_company_id`),
  CONSTRAINT `artists_agent_company_id_foreign` FOREIGN KEY (`agent_company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `artists_default_genre_id_foreign` FOREIGN KEY (`default_genre_id`) REFERENCES `genres` (`id`) ON DELETE SET NULL,
  CONSTRAINT `artists_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cache`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cache` (
  `key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int NOT NULL,
  PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cache_locks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cache_locks` (
  `key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int NOT NULL,
  PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `companies`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `companies` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` enum('supplier','partner','agency','venue','other') COLLATE utf8mb4_unicode_ci NOT NULL,
  `handles_buma` tinyint(1) NOT NULL DEFAULT '0',
  `kvk_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_first_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_last_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `companies_organisation_id_index` (`organisation_id`),
  KEY `companies_kvk_number_index` (`kvk_number`),
  CONSTRAINT `companies_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `crowd_list_persons`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `crowd_list_persons` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `crowd_list_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `person_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `added_at` timestamp NOT NULL,
  `added_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `crowd_list_persons_crowd_list_id_person_id_unique` (`crowd_list_id`,`person_id`),
  KEY `crowd_list_persons_added_by_user_id_foreign` (`added_by_user_id`),
  KEY `crowd_list_persons_person_id_index` (`person_id`),
  CONSTRAINT `crowd_list_persons_added_by_user_id_foreign` FOREIGN KEY (`added_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `crowd_list_persons_crowd_list_id_foreign` FOREIGN KEY (`crowd_list_id`) REFERENCES `crowd_lists` (`id`) ON DELETE CASCADE,
  CONSTRAINT `crowd_list_persons_person_id_foreign` FOREIGN KEY (`person_id`) REFERENCES `persons` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `crowd_lists`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `crowd_lists` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `crowd_type_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` enum('internal','external') COLLATE utf8mb4_unicode_ci NOT NULL,
  `recipient_company_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `auto_approve` tinyint(1) NOT NULL DEFAULT '0',
  `max_persons` int unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `crowd_lists_crowd_type_id_foreign` (`crowd_type_id`),
  KEY `crowd_lists_recipient_company_id_foreign` (`recipient_company_id`),
  KEY `crowd_lists_event_id_type_index` (`event_id`,`type`),
  CONSTRAINT `crowd_lists_crowd_type_id_foreign` FOREIGN KEY (`crowd_type_id`) REFERENCES `crowd_types` (`id`) ON DELETE CASCADE,
  CONSTRAINT `crowd_lists_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `crowd_lists_recipient_company_id_foreign` FOREIGN KEY (`recipient_company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `crowd_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `crowd_types` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `system_type` enum('CREW','GUEST','ARTIST','VOLUNTEER','PRESS','PARTNER','SUPPLIER') COLLATE utf8mb4_unicode_ci NOT NULL,
  `color` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#6366f1',
  `icon` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `crowd_types_organisation_id_system_type_index` (`organisation_id`,`system_type`),
  CONSTRAINT `crowd_types_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `email_change_requests`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_change_requests` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `current_email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `new_email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `requested_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `expires_at` timestamp NOT NULL,
  `verified_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `email_change_requests_requested_by_user_id_foreign` (`requested_by_user_id`),
  KEY `email_change_requests_user_id_status_index` (`user_id`,`status`),
  KEY `email_change_requests_token_index` (`token`),
  CONSTRAINT `email_change_requests_requested_by_user_id_foreign` FOREIGN KEY (`requested_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `email_change_requests_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `email_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `email_logs` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `person_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `recipient_email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `recipient_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `mailable_class` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `template_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `subject` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'queued',
  `error_message` text COLLATE utf8mb4_unicode_ci,
  `queued_at` timestamp NOT NULL,
  `sent_at` timestamp NULL DEFAULT NULL,
  `failed_at` timestamp NULL DEFAULT NULL,
  `triggered_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `email_logs_organisation_id_created_at_index` (`organisation_id`,`created_at`),
  KEY `email_logs_recipient_email_created_at_index` (`recipient_email`,`created_at`),
  KEY `email_logs_template_type_status_index` (`template_type`,`status`),
  KEY `email_logs_event_id_index` (`event_id`),
  KEY `email_logs_person_id_index` (`person_id`),
  CONSTRAINT `email_logs_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE SET NULL,
  CONSTRAINT `email_logs_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `event_person_activations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `event_person_activations` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `person_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `event_person_activations_event_id_person_id_unique` (`event_id`,`person_id`),
  KEY `event_person_activations_person_id_index` (`person_id`),
  KEY `event_person_activations_event_id_index` (`event_id`),
  CONSTRAINT `event_person_activations_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `event_person_activations_person_id_foreign` FOREIGN KEY (`person_id`) REFERENCES `persons` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `event_user_roles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `event_user_roles` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `event_user_roles_user_id_event_id_role_unique` (`user_id`,`event_id`,`role`),
  KEY `event_user_roles_event_id_foreign` (`event_id`),
  CONSTRAINT `event_user_roles_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `event_user_roles_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `events` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `parent_event_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `timezone` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Europe/Amsterdam',
  `status` enum('draft','published','registration_open','buildup','showday','teardown','closed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `event_type` enum('event','festival','series') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'event',
  `event_type_label` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sub_event_label` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_recurring` tinyint(1) NOT NULL DEFAULT '0',
  `recurrence_rule` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `recurrence_exceptions` json DEFAULT NULL,
  `registration_banner_url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `registration_welcome_text` text COLLATE utf8mb4_unicode_ci,
  `registration_logo_url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `registration_show_section_preferences` tinyint(1) NOT NULL DEFAULT '1',
  `registration_show_availability` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `events_organisation_id_slug_unique` (`organisation_id`,`slug`),
  KEY `events_organisation_id_status_index` (`organisation_id`,`status`),
  KEY `events_parent_event_id_index` (`parent_event_id`),
  CONSTRAINT `events_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE,
  CONSTRAINT `events_parent_event_id_foreign` FOREIGN KEY (`parent_event_id`) REFERENCES `events` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `failed_jobs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `failed_jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `festival_sections`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `festival_sections` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `category` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `icon` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` enum('standard','cross_event') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'standard',
  `crew_need` int unsigned DEFAULT NULL,
  `sort_order` int unsigned NOT NULL DEFAULT '0',
  `crew_auto_accepts` tinyint(1) NOT NULL DEFAULT '0',
  `crew_invited_to_events` tinyint(1) NOT NULL DEFAULT '0',
  `added_to_timeline` tinyint(1) NOT NULL DEFAULT '0',
  `responder_self_checkin` tinyint(1) NOT NULL DEFAULT '1',
  `crew_accreditation_level` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `public_form_accreditation_level` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `timed_accreditations` tinyint(1) NOT NULL DEFAULT '0',
  `show_in_registration` tinyint(1) NOT NULL DEFAULT '0',
  `registration_description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `festival_sections_event_id_sort_order_index` (`event_id`,`sort_order`),
  KEY `festival_sections_event_id_category_index` (`event_id`,`category`),
  CONSTRAINT `festival_sections_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_field_bindings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_field_bindings` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner_type` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `target_entity` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `target_attribute` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `mode` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sync_direction` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `merge_strategy` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'overwrite',
  `trust_level` tinyint unsigned NOT NULL DEFAULT '50',
  `is_identity_key` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ffb_owner_target_unique` (`owner_type`,`owner_id`,`target_entity`,`target_attribute`),
  KEY `ffb_target_idx` (`target_entity`,`target_attribute`),
  KEY `ffb_owner_idx` (`owner_type`,`owner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_field_conditional_logic_conditions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_field_conditional_logic_conditions` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `group_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `field_slug` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `comparison_operator` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` json DEFAULT NULL,
  `sort_order` int unsigned NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ffclc_group_sort_idx` (`group_id`,`sort_order`),
  KEY `ffclc_field_slug_idx` (`field_slug`),
  CONSTRAINT `form_field_conditional_logic_conditions_group_id_foreign` FOREIGN KEY (`group_id`) REFERENCES `form_field_conditional_logic_groups` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_field_conditional_logic_groups`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_field_conditional_logic_groups` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_field_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `parent_group_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `operator` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sort_order` int unsigned NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ffclg_field_idx` (`form_field_id`),
  KEY `ffclg_parent_sort_idx` (`parent_group_id`,`sort_order`),
  CONSTRAINT `form_field_conditional_logic_groups_form_field_id_foreign` FOREIGN KEY (`form_field_id`) REFERENCES `form_fields` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_field_conditional_logic_groups_parent_group_id_foreign` FOREIGN KEY (`parent_group_id`) REFERENCES `form_field_conditional_logic_groups` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_field_configs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_field_configs` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner_type` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `config_type` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `parameters` json NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ffc_owner_config_unique` (`owner_type`,`owner_id`,`config_type`),
  KEY `ffc_config_idx` (`config_type`),
  KEY `ffc_owner_idx` (`owner_type`,`owner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_field_library`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_field_library` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `field_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `help_text` text COLLATE utf8mb4_unicode_ci,
  `default_is_required` tinyint(1) NOT NULL DEFAULT '0',
  `default_is_filterable` tinyint(1) NOT NULL DEFAULT '0',
  `translations` json DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `usage_count` int unsigned NOT NULL DEFAULT '0',
  `is_system` tinyint(1) NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ffl_org_slug_unique` (`organisation_id`,`slug`),
  KEY `ffl_org_type_idx` (`organisation_id`,`field_type`),
  KEY `ffl_org_active_idx` (`organisation_id`,`is_active`),
  CONSTRAINT `form_field_library_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_field_options`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_field_options` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner_type` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sort_order` int unsigned NOT NULL DEFAULT '0',
  `translations` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ffo_owner_value_unique` (`owner_type`,`owner_id`,`value`),
  KEY `ffo_owner_sort_idx` (`owner_type`,`owner_id`,`sort_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_field_validation_rules`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_field_validation_rules` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner_type` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `rule_type` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `parameters` json NOT NULL,
  `error_message_key` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ffvr_owner_rule_unique` (`owner_type`,`owner_id`,`rule_type`),
  KEY `ffvr_rule_idx` (`rule_type`),
  KEY `ffvr_owner_idx` (`owner_type`,`owner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_fields`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_fields` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_schema_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_schema_section_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `library_field_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `field_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `help_text` text COLLATE utf8mb4_unicode_ci,
  `section` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_required` tinyint(1) NOT NULL DEFAULT '0',
  `is_filterable` tinyint(1) NOT NULL DEFAULT '0',
  `is_portal_visible` tinyint(1) NOT NULL DEFAULT '1',
  `is_admin_only` tinyint(1) NOT NULL DEFAULT '0',
  `is_unique` tinyint(1) NOT NULL DEFAULT '0',
  `is_pii` tinyint(1) NOT NULL DEFAULT '0',
  `display_width` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'full',
  `role_restrictions` json DEFAULT NULL,
  `translations` json DEFAULT NULL,
  `value_storage_hint` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'json',
  `review_required` tinyint(1) NOT NULL DEFAULT '0',
  `sort_order` int unsigned NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `form_fields_form_schema_section_id_foreign` (`form_schema_section_id`),
  KEY `ff_schema_order_idx` (`form_schema_id`,`sort_order`),
  KEY `ff_schema_filterable_idx` (`form_schema_id`,`is_filterable`),
  KEY `ff_library_idx` (`library_field_id`),
  KEY `ff_schema_slug_idx` (`form_schema_id`,`slug`),
  CONSTRAINT `form_fields_form_schema_id_foreign` FOREIGN KEY (`form_schema_id`) REFERENCES `form_schemas` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_fields_form_schema_section_id_foreign` FOREIGN KEY (`form_schema_section_id`) REFERENCES `form_schema_sections` (`id`) ON DELETE SET NULL,
  CONSTRAINT `form_fields_library_field_id_foreign` FOREIGN KEY (`library_field_id`) REFERENCES `form_field_library` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_schema_sections`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_schema_sections` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_schema_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `sort_order` int unsigned NOT NULL DEFAULT '0',
  `submit_independent` tinyint(1) NOT NULL DEFAULT '1',
  `depends_on_section_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `required_for_schema_submit` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `fss_schema_slug_unique` (`form_schema_id`,`slug`),
  KEY `form_schema_sections_depends_on_section_id_foreign` (`depends_on_section_id`),
  KEY `fss_schema_order_idx` (`form_schema_id`,`sort_order`),
  CONSTRAINT `form_schema_sections_depends_on_section_id_foreign` FOREIGN KEY (`depends_on_section_id`) REFERENCES `form_schema_sections` (`id`) ON DELETE SET NULL,
  CONSTRAINT `form_schema_sections_form_schema_id_foreign` FOREIGN KEY (`form_schema_id`) REFERENCES `form_schemas` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_schema_webhooks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_schema_webhooks` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_schema_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `trigger_event` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `url` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `secret` text COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fsw_schema_active_idx` (`form_schema_id`,`is_active`),
  CONSTRAINT `form_schema_webhooks_form_schema_id_foreign` FOREIGN KEY (`form_schema_id`) REFERENCES `form_schemas` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_schemas`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_schemas` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `owner_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `purpose` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `default_crowd_type_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `is_published` tinyint(1) NOT NULL DEFAULT '0',
  `submission_mode` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `public_token` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `public_token_previous` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `public_token_rotated_at` timestamp NULL DEFAULT NULL,
  `submission_deadline` timestamp NULL DEFAULT NULL,
  `locale` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'nl',
  `settings` json DEFAULT NULL,
  `version` int unsigned NOT NULL DEFAULT '1',
  `snapshot_mode` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'never',
  `freeze_on_submit` tinyint(1) NOT NULL DEFAULT '0',
  `retention_days` int unsigned DEFAULT NULL,
  `consent_version` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `section_level_submit` tinyint(1) NOT NULL DEFAULT '0',
  `auto_save_enabled` tinyint(1) NOT NULL DEFAULT '0',
  `max_submissions` int unsigned DEFAULT NULL,
  `created_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_updated_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `edit_lock_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `edit_lock_expires_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `fs_org_slug_unique` (`organisation_id`,`slug`),
  KEY `form_schemas_created_by_user_id_foreign` (`created_by_user_id`),
  KEY `form_schemas_last_updated_by_user_id_foreign` (`last_updated_by_user_id`),
  KEY `form_schemas_edit_lock_user_id_foreign` (`edit_lock_user_id`),
  KEY `fs_org_purpose_idx` (`organisation_id`,`purpose`),
  KEY `fs_owner_idx` (`owner_type`,`owner_id`),
  KEY `fs_public_token_idx` (`public_token`),
  KEY `fs_public_token_prev_idx` (`public_token_previous`),
  KEY `fs_org_default_crowd_type_idx` (`organisation_id`,`default_crowd_type_id`),
  KEY `form_schemas_default_crowd_type_id_foreign` (`default_crowd_type_id`),
  CONSTRAINT `form_schemas_created_by_user_id_foreign` FOREIGN KEY (`created_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `form_schemas_default_crowd_type_id_foreign` FOREIGN KEY (`default_crowd_type_id`) REFERENCES `crowd_types` (`id`) ON DELETE SET NULL,
  CONSTRAINT `form_schemas_edit_lock_user_id_foreign` FOREIGN KEY (`edit_lock_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `form_schemas_last_updated_by_user_id_foreign` FOREIGN KEY (`last_updated_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `form_schemas_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_submission_action_failure_retry_attempts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_submission_action_failure_retry_attempts` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_submission_action_failure_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `attempted_at` timestamp NOT NULL,
  `attempted_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `outcome` enum('succeeded','failed') COLLATE utf8mb4_unicode_ci NOT NULL,
  `exception_class` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exception_message` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fsafra_user_fk` (`attempted_by_user_id`),
  KEY `fsafra_failure_attempt_idx` (`form_submission_action_failure_id`,`attempted_at`),
  CONSTRAINT `fsafra_failure_fk` FOREIGN KEY (`form_submission_action_failure_id`) REFERENCES `form_submission_action_failures` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fsafra_user_fk` FOREIGN KEY (`attempted_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_submission_action_failures`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_submission_action_failures` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_submission_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `listener_class` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `binding_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `failed_at` timestamp NOT NULL,
  `exception_class` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `exception_message` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `exception_trace` longtext COLLATE utf8mb4_unicode_ci,
  `context` json NOT NULL,
  `retry_count` tinyint unsigned NOT NULL DEFAULT '0',
  `resolved_at` timestamp NULL DEFAULT NULL,
  `resolved_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `resolved_note` text COLLATE utf8mb4_unicode_ci,
  `dismissed_at` timestamp NULL DEFAULT NULL,
  `dismissed_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `dismissed_reason_type` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `dismissed_reason_note` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `form_submission_action_failures_resolved_by_user_id_foreign` (`resolved_by_user_id`),
  KEY `form_submission_action_failures_dismissed_by_user_id_foreign` (`dismissed_by_user_id`),
  KEY `fsaf_submission_idx` (`form_submission_id`),
  KEY `fsaf_listener_failed_idx` (`listener_class`,`failed_at`),
  KEY `fsaf_resolved_idx` (`resolved_at`),
  KEY `fsaf_dismissed_idx` (`dismissed_at`),
  KEY `fsaf_binding_idx` (`binding_id`),
  KEY `fsaf_reason_type_idx` (`dismissed_reason_type`),
  CONSTRAINT `form_submission_action_failures_binding_id_foreign` FOREIGN KEY (`binding_id`) REFERENCES `form_field_bindings` (`id`) ON DELETE SET NULL,
  CONSTRAINT `form_submission_action_failures_dismissed_by_user_id_foreign` FOREIGN KEY (`dismissed_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `form_submission_action_failures_form_submission_id_foreign` FOREIGN KEY (`form_submission_id`) REFERENCES `form_submissions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_submission_action_failures_resolved_by_user_id_foreign` FOREIGN KEY (`resolved_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_submission_delegations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_submission_delegations` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_submission_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `delegated_to_user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `delegated_by_user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `granted_at` timestamp NOT NULL,
  `revoked_at` timestamp NULL DEFAULT NULL,
  `message` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `form_submission_delegations_delegated_by_user_id_foreign` (`delegated_by_user_id`),
  KEY `fsd_delegatee_active_idx` (`delegated_to_user_id`,`revoked_at`),
  KEY `fsd_submission_idx` (`form_submission_id`),
  CONSTRAINT `form_submission_delegations_delegated_by_user_id_foreign` FOREIGN KEY (`delegated_by_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_submission_delegations_delegated_to_user_id_foreign` FOREIGN KEY (`delegated_to_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_submission_delegations_form_submission_id_foreign` FOREIGN KEY (`form_submission_id`) REFERENCES `form_submissions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_submission_section_statuses`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_submission_section_statuses` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_submission_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_schema_section_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
  `submitted_at` timestamp NULL DEFAULT NULL,
  `reviewed_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reviewed_at` timestamp NULL DEFAULT NULL,
  `review_notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `fsss_submission_section_unique` (`form_submission_id`,`form_schema_section_id`),
  KEY `form_submission_section_statuses_form_schema_section_id_foreign` (`form_schema_section_id`),
  KEY `form_submission_section_statuses_reviewed_by_user_id_foreign` (`reviewed_by_user_id`),
  CONSTRAINT `form_submission_section_statuses_form_schema_section_id_foreign` FOREIGN KEY (`form_schema_section_id`) REFERENCES `form_schema_sections` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_submission_section_statuses_form_submission_id_foreign` FOREIGN KEY (`form_submission_id`) REFERENCES `form_submissions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_submission_section_statuses_reviewed_by_user_id_foreign` FOREIGN KEY (`reviewed_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_submissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_submissions` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_schema_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `subject_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `subject_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `submitted_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `public_submitter_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `public_submitter_email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `public_submitter_ip` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `public_submitter_ip_anonymised_at` timestamp NULL DEFAULT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `review_status` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reviewed_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reviewed_at` timestamp NULL DEFAULT NULL,
  `review_notes` text COLLATE utf8mb4_unicode_ci,
  `submitted_at` timestamp NULL DEFAULT NULL,
  `schema_version_at_submit` int unsigned DEFAULT NULL,
  `schema_snapshot` json DEFAULT NULL,
  `is_test` tinyint(1) NOT NULL DEFAULT '0',
  `submitted_in_locale` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `opened_at` timestamp NULL DEFAULT NULL,
  `schema_version_at_open` int unsigned DEFAULT NULL,
  `first_interacted_at` timestamp NULL DEFAULT NULL,
  `submission_duration_seconds` int unsigned DEFAULT NULL,
  `auto_save_count` int unsigned NOT NULL DEFAULT '0',
  `idempotency_key` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `anonymised_at` timestamp NULL DEFAULT NULL,
  `identity_match_status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `apply_status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `failure_response_code` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `apply_completed_at` timestamp NULL DEFAULT NULL,
  `search_index` mediumtext COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `fs_idempotency_unique` (`form_schema_id`,`idempotency_key`),
  KEY `form_submissions_reviewed_by_user_id_foreign` (`reviewed_by_user_id`),
  KEY `fs_schema_status_idx` (`form_schema_id`,`status`),
  KEY `fs_subject_idx` (`subject_type`,`subject_id`),
  KEY `fs_submitter_idx` (`submitted_by_user_id`),
  KEY `fs_schema_review_idx` (`form_schema_id`,`review_status`),
  KEY `fs_schema_identity_match_idx` (`form_schema_id`,`identity_match_status`),
  KEY `fs_org_status_idx` (`organisation_id`,`status`),
  KEY `fs_event_status_idx` (`event_id`,`status`),
  KEY `fs_schema_apply_status_idx` (`form_schema_id`,`apply_status`),
  KEY `fs_org_apply_status_idx` (`organisation_id`,`apply_status`),
  KEY `fs_failure_response_code_idx` (`failure_response_code`),
  FULLTEXT KEY `fs_search_index_fulltext` (`search_index`),
  CONSTRAINT `form_submissions_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE SET NULL,
  CONSTRAINT `form_submissions_form_schema_id_foreign` FOREIGN KEY (`form_schema_id`) REFERENCES `form_schemas` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_submissions_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_submissions_reviewed_by_user_id_foreign` FOREIGN KEY (`reviewed_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `form_submissions_submitted_by_user_id_foreign` FOREIGN KEY (`submitted_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_templates` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `purpose` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `schema_snapshot` json NOT NULL,
  `is_system` tinyint(1) NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ft_org_slug_unique` (`organisation_id`,`slug`),
  KEY `ft_org_purpose_active_idx` (`organisation_id`,`purpose`,`is_active`),
  CONSTRAINT `form_templates_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_value_options`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_value_options` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_value_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_field_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_submission_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `option_value` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fvo_field_option_idx` (`form_field_id`,`option_value`),
  KEY `fvo_submission_idx` (`form_submission_id`),
  KEY `fvo_value_idx` (`form_value_id`),
  CONSTRAINT `form_value_options_form_field_id_foreign` FOREIGN KEY (`form_field_id`) REFERENCES `form_fields` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_value_options_form_submission_id_foreign` FOREIGN KEY (`form_submission_id`) REFERENCES `form_submissions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_value_options_form_value_id_foreign` FOREIGN KEY (`form_value_id`) REFERENCES `form_values` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_values`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_values` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_submission_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_field_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` json NOT NULL,
  `value_indexed` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `value_number` decimal(15,4) DEFAULT NULL,
  `value_date` date DEFAULT NULL,
  `value_bool` tinyint(1) DEFAULT NULL,
  `value_anonymised` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `fv_submission_field_unique` (`form_submission_id`,`form_field_id`),
  KEY `fv_field_indexed_idx` (`form_field_id`,`value_indexed`),
  KEY `fv_field_number_idx` (`form_field_id`,`value_number`),
  KEY `fv_field_date_idx` (`form_field_id`,`value_date`),
  CONSTRAINT `form_values_form_field_id_foreign` FOREIGN KEY (`form_field_id`) REFERENCES `form_fields` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_values_form_submission_id_foreign` FOREIGN KEY (`form_submission_id`) REFERENCES `form_submissions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `form_webhook_deliveries`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `form_webhook_deliveries` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_schema_webhook_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `form_submission_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `trigger_event` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `attempts` int unsigned NOT NULL DEFAULT '0',
  `last_attempt_at` timestamp NULL DEFAULT NULL,
  `response_status` smallint unsigned DEFAULT NULL,
  `response_body_excerpt` text COLLATE utf8mb4_unicode_ci,
  `next_retry_at` timestamp NULL DEFAULT NULL,
  `delivered_at` timestamp NULL DEFAULT NULL,
  `failed_permanently_at` timestamp NULL DEFAULT NULL,
  `payload_snapshot` json NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fwd_status_retry_idx` (`status`,`next_retry_at`),
  KEY `fwd_webhook_status_idx` (`form_schema_webhook_id`,`status`),
  KEY `fwd_submission_idx` (`form_submission_id`),
  CONSTRAINT `form_webhook_deliveries_form_schema_webhook_id_foreign` FOREIGN KEY (`form_schema_webhook_id`) REFERENCES `form_schema_webhooks` (`id`) ON DELETE CASCADE,
  CONSTRAINT `form_webhook_deliveries_form_submission_id_foreign` FOREIGN KEY (`form_submission_id`) REFERENCES `form_submissions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `genres`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `genres` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `color` varchar(7) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sort_order` int NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `genres_organisation_id_name_unique` (`organisation_id`,`name`),
  CONSTRAINT `genres_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `impersonation_sessions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `impersonation_sessions` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `admin_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `target_user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `reason` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `mfa_method` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_agent` text COLLATE utf8mb4_unicode_ci,
  `started_at` timestamp NOT NULL,
  `ended_at` timestamp NULL DEFAULT NULL,
  `expires_at` timestamp NOT NULL,
  `end_reason` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `actions_count` int unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `impersonation_sessions_admin_id_ended_at_index` (`admin_id`,`ended_at`),
  KEY `impersonation_sessions_target_user_id_ended_at_index` (`target_user_id`,`ended_at`),
  KEY `impersonation_sessions_started_at_index` (`started_at`),
  CONSTRAINT `impersonation_sessions_admin_id_foreign` FOREIGN KEY (`admin_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `impersonation_sessions_target_user_id_foreign` FOREIGN KEY (`target_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `job_batches`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `job_batches` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `total_jobs` int NOT NULL,
  `pending_jobs` int NOT NULL,
  `failed_jobs` int NOT NULL,
  `failed_job_ids` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `options` mediumtext COLLATE utf8mb4_unicode_ci,
  `cancelled_at` int DEFAULT NULL,
  `created_at` int NOT NULL,
  `finished_at` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `jobs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `queue` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `attempts` tinyint unsigned NOT NULL,
  `reserved_at` int unsigned DEFAULT NULL,
  `available_at` int unsigned NOT NULL,
  `created_at` int unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `jobs_queue_index` (`queue`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `locations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `locations` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lat` decimal(10,8) DEFAULT NULL,
  `lng` decimal(11,8) DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `access_instructions` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `locations_event_id_index` (`event_id`),
  CONSTRAINT `locations_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mfa_backup_codes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `mfa_backup_codes` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `code_hash` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `used` tinyint(1) NOT NULL DEFAULT '0',
  `used_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `mfa_backup_codes_user_id_used_index` (`user_id`,`used`),
  CONSTRAINT `mfa_backup_codes_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mfa_email_codes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `mfa_email_codes` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` varchar(6) COLLATE utf8mb4_unicode_ci NOT NULL,
  `expires_at` timestamp NOT NULL,
  `used` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `mfa_email_codes_user_id_code_used_expires_at_index` (`user_id`,`code`,`used`,`expires_at`),
  CONSTRAINT `mfa_email_codes_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `migrations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `migrations` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `model_has_permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `model_has_permissions` (
  `permission_id` bigint unsigned NOT NULL,
  `model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_id` varchar(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`permission_id`,`model_id`,`model_type`),
  KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`),
  CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `model_has_roles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `model_has_roles` (
  `role_id` bigint unsigned NOT NULL,
  `model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_id` varchar(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`role_id`,`model_id`,`model_type`),
  KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`),
  CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `organisation_email_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `organisation_email_settings` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `logo_url` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `primary_color` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#6366F1',
  `secondary_color` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#4F46E5',
  `footer_text` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reply_to_email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reply_to_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `organisation_email_settings_organisation_id_unique` (`organisation_id`),
  CONSTRAINT `organisation_email_settings_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `organisation_email_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `organisation_email_templates` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `subject` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
  `heading` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `body_text` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `button_text` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `organisation_email_templates_organisation_id_type_unique` (`organisation_id`,`type`),
  CONSTRAINT `organisation_email_templates_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `organisation_user`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `organisation_user` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `organisation_user_user_id_organisation_id_unique` (`user_id`,`organisation_id`),
  KEY `organisation_user_organisation_id_foreign` (`organisation_id`),
  CONSTRAINT `organisation_user_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE,
  CONSTRAINT `organisation_user_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `organisations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `organisations` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `contact_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `website` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `billing_status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'trial',
  `default_locale` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'nl',
  `settings` json DEFAULT NULL,
  `email_logo_url` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_primary_color` varchar(7) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_reply_to` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_sender_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_footer_text` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `organisations_slug_unique` (`slug`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `password_reset_tokens`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `password_reset_tokens` (
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `performances`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `performances` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `engagement_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `stage_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lane` tinyint unsigned NOT NULL DEFAULT '0',
  `start_at` datetime NOT NULL,
  `end_at` datetime NOT NULL,
  `version` int NOT NULL DEFAULT '0',
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `performances_event_id_stage_id_start_at_end_at_index` (`event_id`,`stage_id`,`start_at`,`end_at`),
  KEY `performances_engagement_id_index` (`engagement_id`),
  KEY `performances_stage_id_start_at_index` (`stage_id`,`start_at`),
  CONSTRAINT `performances_engagement_id_foreign` FOREIGN KEY (`engagement_id`) REFERENCES `artist_engagements` (`id`) ON DELETE CASCADE,
  CONSTRAINT `performances_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `performances_stage_id_foreign` FOREIGN KEY (`stage_id`) REFERENCES `stages` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `permissions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `guard_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `permissions_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `person_identity_matches`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `person_identity_matches` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `person_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `matched_user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `matched_on` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `confidence` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `match_details` json DEFAULT NULL,
  `confirmed_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `confirmed_at` timestamp NULL DEFAULT NULL,
  `dismissed_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `dismissed_at` timestamp NULL DEFAULT NULL,
  `reverted_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reverted_at` timestamp NULL DEFAULT NULL,
  `resolved_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `resolved_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `person_identity_matches_person_id_matched_user_id_unique` (`person_id`,`matched_user_id`),
  KEY `person_identity_matches_resolved_by_user_id_foreign` (`resolved_by_user_id`),
  KEY `person_identity_matches_person_id_status_index` (`person_id`,`status`),
  KEY `person_identity_matches_matched_user_id_status_index` (`matched_user_id`,`status`),
  KEY `person_identity_matches_status_index` (`status`),
  KEY `person_identity_matches_confirmed_by_user_id_foreign` (`confirmed_by_user_id`),
  KEY `person_identity_matches_dismissed_by_user_id_foreign` (`dismissed_by_user_id`),
  KEY `person_identity_matches_reverted_by_user_id_foreign` (`reverted_by_user_id`),
  CONSTRAINT `person_identity_matches_confirmed_by_user_id_foreign` FOREIGN KEY (`confirmed_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `person_identity_matches_dismissed_by_user_id_foreign` FOREIGN KEY (`dismissed_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `person_identity_matches_matched_user_id_foreign` FOREIGN KEY (`matched_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `person_identity_matches_person_id_foreign` FOREIGN KEY (`person_id`) REFERENCES `persons` (`id`) ON DELETE CASCADE,
  CONSTRAINT `person_identity_matches_resolved_by_user_id_foreign` FOREIGN KEY (`resolved_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `person_identity_matches_reverted_by_user_id_foreign` FOREIGN KEY (`reverted_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `person_section_preferences`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `person_section_preferences` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `person_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `festival_section_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `priority` tinyint NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `psp_person_section_unique` (`person_id`,`festival_section_id`),
  KEY `person_section_preferences_festival_section_id_priority_index` (`festival_section_id`,`priority`),
  KEY `psp_person_index` (`person_id`),
  CONSTRAINT `person_section_preferences_festival_section_id_foreign` FOREIGN KEY (`festival_section_id`) REFERENCES `festival_sections` (`id`) ON DELETE CASCADE,
  CONSTRAINT `person_section_preferences_person_id_foreign` FOREIGN KEY (`person_id`) REFERENCES `persons` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `person_tags`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `person_tags` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `category` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `icon` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `color` varchar(7) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `sort_order` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `person_tags_organisation_id_name_unique` (`organisation_id`,`name`),
  KEY `person_tags_organisation_id_is_active_sort_order_index` (`organisation_id`,`is_active`,`sort_order`),
  CONSTRAINT `person_tags_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `personal_access_tokens`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `personal_access_tokens` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tokenable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tokenable_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `abilities` text COLLATE utf8mb4_unicode_ci,
  `last_used_at` timestamp NULL DEFAULT NULL,
  `expires_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `personal_access_tokens_token_unique` (`token`),
  KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`),
  KEY `personal_access_tokens_expires_at_index` (`expires_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `persons`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `persons` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `crowd_type_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `company_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `first_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `date_of_birth` date DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('invited','applied','pending','approved','rejected','no_show') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `registration_source` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'organizer',
  `is_blacklisted` tinyint(1) NOT NULL DEFAULT '0',
  `admin_notes` text COLLATE utf8mb4_unicode_ci,
  `remarks` text COLLATE utf8mb4_unicode_ci,
  `custom_fields` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `persons_crowd_type_id_foreign` (`crowd_type_id`),
  KEY `persons_company_id_foreign` (`company_id`),
  KEY `persons_event_id_crowd_type_id_status_index` (`event_id`,`crowd_type_id`,`status`),
  KEY `persons_email_event_id_index` (`email`,`event_id`),
  KEY `persons_user_id_event_id_index` (`user_id`,`event_id`),
  CONSTRAINT `persons_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `persons_crowd_type_id_foreign` FOREIGN KEY (`crowd_type_id`) REFERENCES `crowd_types` (`id`) ON DELETE CASCADE,
  CONSTRAINT `persons_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `persons_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `role_has_permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `role_has_permissions` (
  `permission_id` bigint unsigned NOT NULL,
  `role_id` bigint unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`role_id`),
  KEY `role_has_permissions_role_id_foreign` (`role_id`),
  CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `roles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `roles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `guard_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `roles_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sessions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sessions` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` text COLLATE utf8mb4_unicode_ci,
  `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_activity` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `sessions_user_id_index` (`user_id`),
  KEY `sessions_last_activity_index` (`last_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `shift_absences`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `shift_absences` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `shift_assignment_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `person_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `reason` enum('sick','personal','other') COLLATE utf8mb4_unicode_ci NOT NULL,
  `reported_at` timestamp NOT NULL,
  `status` enum('open','filled','closed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',
  `closed_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `shift_absences_person_id_foreign` (`person_id`),
  KEY `shift_absences_shift_assignment_id_index` (`shift_assignment_id`),
  KEY `shift_absences_status_index` (`status`),
  CONSTRAINT `shift_absences_person_id_foreign` FOREIGN KEY (`person_id`) REFERENCES `persons` (`id`) ON DELETE CASCADE,
  CONSTRAINT `shift_absences_shift_assignment_id_foreign` FOREIGN KEY (`shift_assignment_id`) REFERENCES `shift_assignments` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `shift_assignments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `shift_assignments` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `shift_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `person_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `time_slot_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('pending_approval','approved','rejected','cancelled','completed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending_approval',
  `auto_approved` tinyint(1) NOT NULL DEFAULT '0',
  `assigned_by` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `assigned_at` timestamp NULL DEFAULT NULL,
  `approved_by` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `approved_at` timestamp NULL DEFAULT NULL,
  `rejection_reason` text COLLATE utf8mb4_unicode_ci,
  `cancelled_by` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cancellation_source` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cancelled_at` timestamp NULL DEFAULT NULL,
  `hours_expected` decimal(4,2) DEFAULT NULL,
  `hours_completed` decimal(4,2) DEFAULT NULL,
  `checked_in_at` timestamp NULL DEFAULT NULL,
  `checked_out_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `shift_assignments_time_slot_id_foreign` (`time_slot_id`),
  KEY `shift_assignments_assigned_by_foreign` (`assigned_by`),
  KEY `shift_assignments_approved_by_foreign` (`approved_by`),
  KEY `shift_assignments_shift_id_status_index` (`shift_id`,`status`),
  KEY `shift_assignments_person_id_status_index` (`person_id`,`status`),
  KEY `shift_assignments_person_id_time_slot_id_index` (`person_id`,`time_slot_id`),
  KEY `shift_assignments_cancelled_by_foreign` (`cancelled_by`),
  CONSTRAINT `shift_assignments_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shift_assignments_assigned_by_foreign` FOREIGN KEY (`assigned_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shift_assignments_cancelled_by_foreign` FOREIGN KEY (`cancelled_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shift_assignments_person_id_foreign` FOREIGN KEY (`person_id`) REFERENCES `persons` (`id`) ON DELETE CASCADE,
  CONSTRAINT `shift_assignments_shift_id_foreign` FOREIGN KEY (`shift_id`) REFERENCES `shifts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `shift_assignments_time_slot_id_foreign` FOREIGN KEY (`time_slot_id`) REFERENCES `time_slots` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `shift_check_ins`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `shift_check_ins` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `shift_assignment_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `person_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `shift_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `checked_in_at` timestamp NOT NULL,
  `checked_out_at` timestamp NULL DEFAULT NULL,
  `checked_in_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `method` enum('qr','manual') COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `shift_check_ins_checked_in_by_user_id_foreign` (`checked_in_by_user_id`),
  KEY `shift_check_ins_shift_assignment_id_index` (`shift_assignment_id`),
  KEY `shift_check_ins_shift_id_checked_in_at_index` (`shift_id`,`checked_in_at`),
  KEY `shift_check_ins_person_id_checked_in_at_index` (`person_id`,`checked_in_at`),
  CONSTRAINT `shift_check_ins_checked_in_by_user_id_foreign` FOREIGN KEY (`checked_in_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shift_check_ins_person_id_foreign` FOREIGN KEY (`person_id`) REFERENCES `persons` (`id`) ON DELETE CASCADE,
  CONSTRAINT `shift_check_ins_shift_assignment_id_foreign` FOREIGN KEY (`shift_assignment_id`) REFERENCES `shift_assignments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `shift_check_ins_shift_id_foreign` FOREIGN KEY (`shift_id`) REFERENCES `shifts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `shift_swap_requests`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `shift_swap_requests` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `from_assignment_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `to_person_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `message` text COLLATE utf8mb4_unicode_ci,
  `status` enum('pending','accepted','rejected','cancelled','completed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `reviewed_by` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reviewed_at` timestamp NULL DEFAULT NULL,
  `auto_approved` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `shift_swap_requests_reviewed_by_foreign` (`reviewed_by`),
  KEY `shift_swap_requests_from_assignment_id_index` (`from_assignment_id`),
  KEY `shift_swap_requests_to_person_id_status_index` (`to_person_id`,`status`),
  CONSTRAINT `shift_swap_requests_from_assignment_id_foreign` FOREIGN KEY (`from_assignment_id`) REFERENCES `shift_assignments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `shift_swap_requests_reviewed_by_foreign` FOREIGN KEY (`reviewed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shift_swap_requests_to_person_id_foreign` FOREIGN KEY (`to_person_id`) REFERENCES `persons` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `shift_waitlist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `shift_waitlist` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `shift_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `person_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `position` int unsigned NOT NULL,
  `added_at` timestamp NOT NULL,
  `notified_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `shift_waitlist_shift_id_person_id_unique` (`shift_id`,`person_id`),
  KEY `shift_waitlist_person_id_foreign` (`person_id`),
  KEY `shift_waitlist_shift_id_position_index` (`shift_id`,`position`),
  CONSTRAINT `shift_waitlist_person_id_foreign` FOREIGN KEY (`person_id`) REFERENCES `persons` (`id`) ON DELETE CASCADE,
  CONSTRAINT `shift_waitlist_shift_id_foreign` FOREIGN KEY (`shift_id`) REFERENCES `shifts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `shifts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `shifts` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `festival_section_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `time_slot_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `location_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `report_time` time DEFAULT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `instructions` text COLLATE utf8mb4_unicode_ci,
  `coordinator_notes` text COLLATE utf8mb4_unicode_ci,
  `slots_total` int unsigned NOT NULL,
  `slots_open_for_claiming` int unsigned NOT NULL,
  `is_lead_role` tinyint(1) NOT NULL DEFAULT '0',
  `actual_start_time` time DEFAULT NULL,
  `actual_end_time` time DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `allow_overlap` tinyint(1) NOT NULL DEFAULT '0',
  `assigned_crew_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `events_during_shift` json DEFAULT NULL,
  `status` enum('draft','open','full','in_progress','completed','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `shifts_location_id_foreign` (`location_id`),
  KEY `shifts_festival_section_id_time_slot_id_index` (`festival_section_id`,`time_slot_id`),
  KEY `shifts_time_slot_id_status_index` (`time_slot_id`,`status`),
  KEY `shifts_assigned_crew_id_foreign` (`assigned_crew_id`),
  CONSTRAINT `shifts_assigned_crew_id_foreign` FOREIGN KEY (`assigned_crew_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shifts_festival_section_id_foreign` FOREIGN KEY (`festival_section_id`) REFERENCES `festival_sections` (`id`) ON DELETE CASCADE,
  CONSTRAINT `shifts_location_id_foreign` FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shifts_time_slot_id_foreign` FOREIGN KEY (`time_slot_id`) REFERENCES `time_slots` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `stage_days`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `stage_days` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `stage_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `stage_days_stage_id_event_id_unique` (`stage_id`,`event_id`),
  KEY `stage_days_event_id_index` (`event_id`),
  CONSTRAINT `stage_days_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `stage_days_stage_id_foreign` FOREIGN KEY (`stage_id`) REFERENCES `stages` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `stages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `stages` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
  `color` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL,
  `capacity` int DEFAULT NULL,
  `sort_order` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `stages_event_id_name_unique` (`event_id`,`name`),
  KEY `stages_event_id_sort_order_index` (`event_id`,`sort_order`),
  CONSTRAINT `stages_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `telescope_entries`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `telescope_entries` (
  `sequence` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `family_hash` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `should_display_on_index` tinyint(1) NOT NULL DEFAULT '1',
  `type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `content` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` datetime DEFAULT NULL,
  PRIMARY KEY (`sequence`),
  UNIQUE KEY `telescope_entries_uuid_unique` (`uuid`),
  KEY `telescope_entries_batch_id_index` (`batch_id`),
  KEY `telescope_entries_family_hash_index` (`family_hash`),
  KEY `telescope_entries_created_at_index` (`created_at`),
  KEY `telescope_entries_type_should_display_on_index_index` (`type`,`should_display_on_index`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `telescope_entries_tags`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `telescope_entries_tags` (
  `entry_uuid` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tag` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`entry_uuid`,`tag`),
  KEY `telescope_entries_tags_tag_index` (`tag`),
  CONSTRAINT `telescope_entries_tags_entry_uuid_foreign` FOREIGN KEY (`entry_uuid`) REFERENCES `telescope_entries` (`uuid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `telescope_monitoring`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `telescope_monitoring` (
  `tag` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `time_slots`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `time_slots` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `person_type` enum('CREW','VOLUNTEER','PRESS','PHOTO','PARTNER') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'VOLUNTEER',
  `date` date NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `duration_hours` decimal(4,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `time_slots_event_id_person_type_date_index` (`event_id`,`person_type`,`date`),
  CONSTRAINT `time_slots_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `trusted_devices`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `trusted_devices` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `device_hash` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `device_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
  `trusted_until` timestamp NOT NULL,
  `last_used_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `trusted_devices_user_id_device_hash_trusted_until_index` (`user_id`,`device_hash`,`trusted_until`),
  CONSTRAINT `trusted_devices_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `user_invitations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user_invitations` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `invited_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `role` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` char(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('pending','accepted','expired') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `expires_at` timestamp NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_invitations_token_unique` (`token`),
  KEY `user_invitations_organisation_id_foreign` (`organisation_id`),
  KEY `user_invitations_event_id_foreign` (`event_id`),
  KEY `user_invitations_email_status_index` (`email`,`status`),
  KEY `user_invitations_invited_by_user_id_foreign` (`invited_by_user_id`),
  CONSTRAINT `user_invitations_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `user_invitations_invited_by_user_id_foreign` FOREIGN KEY (`invited_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `user_invitations_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `user_organisation_tags`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user_organisation_tags` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `organisation_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `person_tag_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `source` enum('self_reported','organiser_assigned') COLLATE utf8mb4_unicode_ci NOT NULL,
  `assigned_by_user_id` char(26) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `proficiency` enum('beginner','experienced','expert') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `assigned_at` timestamp NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uot_user_org_tag_source_unique` (`user_id`,`organisation_id`,`person_tag_id`,`source`),
  KEY `user_organisation_tags_assigned_by_user_id_foreign` (`assigned_by_user_id`),
  KEY `user_organisation_tags_user_id_organisation_id_index` (`user_id`,`organisation_id`),
  KEY `user_organisation_tags_person_tag_id_index` (`person_tag_id`),
  KEY `uot_org_tag_proficiency_index` (`organisation_id`,`person_tag_id`,`proficiency`),
  CONSTRAINT `user_organisation_tags_assigned_by_user_id_foreign` FOREIGN KEY (`assigned_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `user_organisation_tags_organisation_id_foreign` FOREIGN KEY (`organisation_id`) REFERENCES `organisations` (`id`) ON DELETE CASCADE,
  CONSTRAINT `user_organisation_tags_person_tag_id_foreign` FOREIGN KEY (`person_tag_id`) REFERENCES `person_tags` (`id`) ON DELETE CASCADE,
  CONSTRAINT `user_organisation_tags_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `user_profiles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user_profiles` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `bio` text COLLATE utf8mb4_unicode_ci,
  `photo_url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `emergency_contact_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `emergency_contact_phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reliability_score` decimal(3,2) NOT NULL DEFAULT '0.00',
  `is_ambassador` tinyint(1) NOT NULL DEFAULT '0',
  `settings` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_profiles_user_id_unique` (`user_id`),
  KEY `user_profiles_reliability_index` (`reliability_score`),
  CONSTRAINT `user_profiles_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `first_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `date_of_birth` date DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `mfa_enabled` tinyint(1) NOT NULL DEFAULT '0',
  `mfa_method` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `mfa_secret` text COLLATE utf8mb4_unicode_ci,
  `mfa_confirmed_at` timestamp NULL DEFAULT NULL,
  `mfa_enforced` tinyint(1) NOT NULL DEFAULT '0',
  `email_verified_at` timestamp NULL DEFAULT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `timezone` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Europe/Amsterdam',
  `locale` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'nl',
  `avatar` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `volunteer_availabilities`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `volunteer_availabilities` (
  `id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `person_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `time_slot_id` char(26) COLLATE utf8mb4_unicode_ci NOT NULL,
  `preference_level` tinyint NOT NULL DEFAULT '3',
  `submitted_at` timestamp NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `volunteer_availabilities_person_id_time_slot_id_unique` (`person_id`,`time_slot_id`),
  KEY `volunteer_availabilities_time_slot_id_index` (`time_slot_id`),
  CONSTRAINT `volunteer_availabilities_person_id_foreign` FOREIGN KEY (`person_id`) REFERENCES `persons` (`id`) ON DELETE CASCADE,
  CONSTRAINT `volunteer_availabilities_time_slot_id_foreign` FOREIGN KEY (`time_slot_id`) REFERENCES `time_slots` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- WARNING: can't read the INFORMATION_SCHEMA.libraries table. It's most probably an old server 8.0.44.
--
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (1,'0001_01_01_000000_create_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (2,'0001_01_01_000001_create_cache_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (3,'0001_01_01_000002_create_jobs_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (4,'2026_04_07_100000_create_personal_access_tokens_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (5,'2026_04_07_110000_create_permission_tables',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (6,'2026_04_07_120000_create_activity_log_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (7,'2026_04_07_200000_create_organisations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (8,'2026_04_07_210000_create_organisation_user_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (9,'2026_04_07_220000_create_events_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (10,'2026_04_07_230000_create_user_invitations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (11,'2026_04_07_240000_create_event_user_roles_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (12,'2026_04_07_250000_fix_organisations_and_invitations',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (13,'2026_04_07_260000_create_locations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (14,'2026_04_07_270000_create_festival_sections_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (15,'2026_04_07_280000_create_time_slots_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (16,'2026_04_08_100000_remove_volunteer_min_hours_from_events',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (17,'2026_04_08_110000_remove_route_geojson_from_locations',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (18,'2026_04_08_120000_add_section_settings_to_festival_sections',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (19,'2026_04_08_130000_create_shifts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (20,'2026_04_08_140000_create_shift_assignments_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (21,'2026_04_08_150000_create_shift_check_ins_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (22,'2026_04_08_160000_create_volunteer_availabilities_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (23,'2026_04_08_200000_create_crowd_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (24,'2026_04_08_205712_add_category_and_icon_to_festival_sections_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (25,'2026_04_08_210000_create_companies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (26,'2026_04_08_220000_create_persons_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (27,'2026_04_08_230000_create_crowd_lists_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (28,'2026_04_08_240000_create_crowd_list_persons_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (29,'2026_04_08_250000_add_person_foreign_keys_to_existing_tables',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (30,'2026_04_08_300000_add_shifts_extras_and_waitlist_tables',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (31,'2026_04_08_310000_drop_unique_person_timeslot_on_shift_assignments',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (32,'2026_04_08_320000_fix_activity_log_morphs_to_ulid',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (33,'2026_04_08_400000_add_festival_columns_to_events_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (34,'2026_04_08_410000_create_event_person_activations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (35,'2026_04_10_100000_add_registration_branding_to_events_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (36,'2026_04_10_100000_create_person_tags_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (37,'2026_04_10_110000_create_user_organisation_tags_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (38,'2026_04_10_193837_add_cancellation_tracking_to_shift_assignments',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (39,'2026_04_10_200000_create_person_identity_matches_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (40,'2026_04_10_300000_add_registration_fields_to_festival_sections_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (41,'2026_04_10_400000_split_name_into_first_last_on_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (42,'2026_04_10_400001_split_name_into_first_last_on_persons_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (43,'2026_04_10_400002_split_contact_name_on_companies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (44,'2026_04_10_500000_add_date_of_birth_to_persons_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (45,'2026_04_12_100000_add_remarks_to_persons_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (46,'2026_04_12_100001_add_registration_toggles_to_events_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (47,'2026_04_12_200000_create_registration_field_templates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (48,'2026_04_12_200001_create_registration_form_fields_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (49,'2026_04_12_200002_create_person_field_values_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (50,'2026_04_12_200003_create_person_section_preferences_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (51,'2026_04_13_100000_add_email_branding_to_organisations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (52,'2026_04_14_100000_update_token_columns_for_hashed_storage',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (53,'2026_04_14_200000_add_date_of_birth_to_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (54,'2026_04_14_200001_enhance_person_identity_matches_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (55,'2026_04_14_300000_create_email_change_requests_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (56,'2026_04_15_100000_create_organisation_email_settings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (57,'2026_04_15_100001_create_organisation_email_templates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (58,'2026_04_15_100002_create_email_logs_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (59,'2026_04_15_200000_add_mfa_columns_to_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (60,'2026_04_15_200001_create_mfa_backup_codes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (61,'2026_04_15_200002_create_trusted_devices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (62,'2026_04_15_200003_create_mfa_email_codes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (63,'2026_04_16_000000_add_phone_to_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (64,'2026_04_16_100000_create_impersonation_sessions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (65,'2026_04_16_142626_remove_section_from_registration_fields_tables',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (66,'2026_04_17_100000_add_registration_source_to_persons_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (67,'2026_04_17_200000_add_display_width_to_registration_fields_tables',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (68,'2026_04_18_100000_change_tag_category_to_tag_categories_on_registration_fields',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (69,'2026_04_18_100001_update_partner_crowd_type_icon',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (70,'2026_04_18_110000_add_contact_fields_to_organisations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (71,'2026_04_19_100000_create_user_profiles_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (72,'2026_04_19_100001_populate_user_profiles_from_existing_users',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (73,'2026_04_19_100002_create_form_schemas_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (74,'2026_04_19_100003_create_form_schema_sections_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (75,'2026_04_19_100004_create_form_field_library_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (76,'2026_04_19_100005_create_form_fields_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (77,'2026_04_19_100006_create_form_submissions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (78,'2026_04_19_100007_create_form_submission_section_statuses_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (79,'2026_04_19_100008_create_form_submission_delegations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (80,'2026_04_19_100009_create_form_values_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (81,'2026_04_19_100010_create_form_value_options_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (82,'2026_04_19_100011_create_form_templates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (83,'2026_04_19_100012_create_form_schema_webhooks_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (84,'2026_04_19_100013_create_form_webhook_deliveries_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (85,'2026_04_20_100000_drop_remaining_legacy_registration_tables',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (86,'2026_04_21_100000_add_default_locale_to_organisations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (87,'2026_04_22_100000_add_identity_match_status_to_form_submissions',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (88,'2026_04_22_100001_add_idempotency_key_unique_to_form_submissions',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (89,'2026_04_22_100002_add_schema_version_at_open_to_form_submissions',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (90,'2026_04_24_100000_purge_invalid_form_purposes',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (91,'2026_04_24_100001_drop_custom_purpose_slug_from_form_schemas',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (92,'2026_04_24_110001_migrate_organisation_user_to_ulid',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (93,'2026_04_24_110002_migrate_event_user_roles_to_ulid',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (94,'2026_04_24_110003_migrate_crowd_list_persons_to_ulid',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (95,'2026_04_24_110004_migrate_event_person_activations_to_ulid',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (96,'2026_04_24_110005_migrate_user_organisation_tags_to_ulid',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (97,'2026_04_24_110006_migrate_person_section_preferences_to_ulid',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (98,'2026_04_24_110007_migrate_mfa_backup_codes_to_ulid',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (99,'2026_04_24_110008_migrate_mfa_email_codes_to_ulid',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (100,'2026_04_24_110009_migrate_form_submission_section_statuses_to_ulid',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (101,'2026_04_24_110010_migrate_form_values_and_options_to_ulid',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (102,'2026_04_24_200000_add_denormalized_context_to_form_submissions',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (103,'2026_04_25_015838_create_telescope_entries_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (104,'2026_04_25_100000_create_form_field_bindings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (105,'2026_04_25_100001_drop_binding_json_columns',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (106,'2026_04_25_110000_create_form_field_validation_rules_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (107,'2026_04_25_110001_backfill_form_field_validation_rules',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (108,'2026_04_25_120000_create_form_field_configs_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (109,'2026_04_25_120001_backfill_form_field_configs',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (110,'2026_04_25_120002_drop_validation_rules_json_columns',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (111,'2026_04_25_140000_extend_form_submissions_with_apply_status',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (112,'2026_04_25_140100_create_form_submission_action_failures',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (113,'2026_04_26_100000_create_form_field_conditional_logic_groups_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (114,'2026_04_26_100001_create_form_field_conditional_logic_conditions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (115,'2026_04_26_100002_backfill_form_field_conditional_logic',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (116,'2026_04_26_100003_drop_conditional_logic_json_column',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (117,'2026_04_26_120000_add_default_crowd_type_id_to_form_schemas',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (118,'2026_04_27_100000_create_form_field_options_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (119,'2026_04_27_100001_backfill_form_field_options',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (120,'2026_04_27_100002_drop_form_field_options_json_columns',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (121,'2026_04_28_100000_restore_default_crowd_type_id_foreign_key',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (122,'2026_04_28_140000_add_kvk_number_to_companies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (123,'2026_04_28_180000_create_form_submission_action_failure_retry_attempts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (124,'2026_04_28_181000_add_exception_trace_to_form_submission_action_failures',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (125,'2026_05_08_000001_add_failure_response_code_to_form_submissions',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (136,'2026_05_08_100000_create_genres_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (137,'2026_05_08_100001_create_artists_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (138,'2026_05_08_100002_add_handles_buma_to_companies_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (139,'2026_05_08_100003_create_artist_contacts_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (140,'2026_05_08_100004_create_stages_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (141,'2026_05_08_100005_create_stage_days_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (142,'2026_05_08_100006_create_artist_engagements_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (143,'2026_05_08_100007_create_performances_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (144,'2026_05_08_100008_create_advance_sections_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (145,'2026_05_08_100009_create_advance_submissions_table',2);
