CREATE TABLE `meditation_sessions` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `title` VARCHAR(180) NOT NULL,
  `description` TEXT NULL,
  `starts_at` DATETIME NOT NULL,
  `ends_at` DATETIME NOT NULL,
  `timezone` VARCHAR(64) NOT NULL DEFAULT 'Europe/Paris',
  `price_cents` INT UNSIGNED NOT NULL DEFAULT 500,
  `currency` CHAR(3) NOT NULL DEFAULT 'eur',
  `delivery_mode` ENUM('online','in_person','hybrid') NOT NULL DEFAULT 'online',
  `meeting_provider` VARCHAR(40) NULL,
  `zoom_url` VARCHAR(2048) NULL,
  `status` ENUM('draft','published','cancelled') NOT NULL DEFAULT 'draft',
  `created_at` DATETIME NOT NULL,
  `updated_at` DATETIME NOT NULL,
  PRIMARY KEY (`id`), UNIQUE KEY `meditation_start_unique` (`starts_at`), KEY `meditation_public_idx` (`status`,`starts_at`)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

CREATE TABLE `meditation_bookings` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `session_id` BIGINT UNSIGNED NOT NULL,
  `name` VARCHAR(120) NOT NULL,
  `email` VARCHAR(190) NOT NULL,
  `amount_cents` INT UNSIGNED NOT NULL,
  `currency` CHAR(3) NOT NULL DEFAULT 'eur',
  `status` ENUM('pending','paid','cancelled','refunded') NOT NULL DEFAULT 'pending',
  `stripe_checkout_session_id` VARCHAR(255) NULL,
  `stripe_payment_intent_id` VARCHAR(255) NULL,
  `paid_at` DATETIME NULL,
  `mail_sent_at` DATETIME NULL,
  `created_at` DATETIME NOT NULL,
  `updated_at` DATETIME NOT NULL,
  PRIMARY KEY (`id`), UNIQUE KEY `meditation_checkout_unique` (`stripe_checkout_session_id`), KEY `meditation_booking_idx` (`session_id`,`status`),
  CONSTRAINT `meditation_booking_session_fk` FOREIGN KEY (`session_id`) REFERENCES `meditation_sessions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
