-- Restless Dreamers - Weekend Sessions App
-- Production Database Schema (MySQL 5.7+ / 8.0+ / MariaDB 10.3+)
-- Charset: utf8mb4, Collation: utf8mb4_unicode_ci

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- 1. Users Table
CREATE TABLE IF NOT EXISTS `users` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `email` VARCHAR(255) NOT NULL UNIQUE,
  `name` VARCHAR(255) NOT NULL,
  `role` VARCHAR(50) NOT NULL DEFAULT 'member', -- 'admin', 'curator', 'member'
  `notification_preferences` TEXT,
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 2. Taste Profiles Table
CREATE TABLE IF NOT EXISTS `profiles` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT NOT NULL UNIQUE,
  `interests` TEXT NOT NULL, -- JSON array of topics
  `whatsapp` VARCHAR(30) NULL,
  `linkedin_url` VARCHAR(255) NULL,
  `weekly_minutes` INT NOT NULL DEFAULT 60,
  `reading_depth` VARCHAR(50) NOT NULL DEFAULT 'standard', -- 'skim', 'standard', 'deep'
  `headline_preferences` TEXT,
  `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 3. Items (Content Pool / Multidisciplinary Readings)
CREATE TABLE IF NOT EXISTS `items` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `url` TEXT NOT NULL,
  `canonical_url` VARCHAR(500) NOT NULL,
  `title` VARCHAR(500) NOT NULL,
  `description` TEXT,
  `thumbnail_path` TEXT,
  `source` VARCHAR(255),
  `favicon` TEXT,
  `type` VARCHAR(50) NOT NULL DEFAULT 'article', -- 'article', 'video', 'podcast', 'paper', 'book'
  `tier` VARCHAR(50) NOT NULL DEFAULT 'easy', -- 'easy', 'stretch', 'wildcard'
  `discipline` VARCHAR(100) NOT NULL DEFAULT 'culture', -- 'psychology', 'culture', 'science', 'marketing', 'economics'
  `tags` TEXT, -- JSON array
  `time_estimate` INT NOT NULL DEFAULT 5, -- in minutes
  `why_note` TEXT,
  `status` VARCHAR(50) NOT NULL DEFAULT 'published', -- 'draft', 'scheduled', 'published'
  `health_status` VARCHAR(50) NOT NULL DEFAULT 'ok',
  `created_by` INT,
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 4. Drops (Weekly Phenomenon Salons)
CREATE TABLE IF NOT EXISTS `drops` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `week_slug` VARCHAR(50) NOT NULL UNIQUE,
  `title` VARCHAR(255) NOT NULL,
  `phenomenon` VARCHAR(255) NOT NULL,
  `primer` TEXT NOT NULL,
  `session_time` DATETIME NOT NULL,
  `session_link` TEXT,
  `replay_link` TEXT,
  `recap_notes` TEXT,
  `status` VARCHAR(50) NOT NULL DEFAULT 'published', -- 'draft', 'scheduled', 'published', 'archived'
  `is_paid` INT NOT NULL DEFAULT 0, -- 0 = Free, 1 = Paid Session
  `price_inr` DECIMAL(10, 2) NOT NULL DEFAULT 0.00,
  `capacity` INT NOT NULL DEFAULT 30,
  `sales_open_at` DATETIME,
  `sales_close_at` DATETIME,
  `published_at` DATETIME,
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 5. Drop Items (5 Lenses Mapping)
CREATE TABLE IF NOT EXISTS `drop_items` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `drop_id` INT NOT NULL,
  `item_id` INT NOT NULL,
  `lens` VARCHAR(100) NOT NULL,
  `display_order` INT NOT NULL DEFAULT 0,
  FOREIGN KEY (`drop_id`) REFERENCES `drops`(`id`) ON DELETE CASCADE,
  FOREIGN KEY (`item_id`) REFERENCES `items`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 6. Member Personalized Reading Plans
CREATE TABLE IF NOT EXISTS `plans` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT NOT NULL,
  `drop_id` INT NOT NULL,
  `status` VARCHAR(50) NOT NULL DEFAULT 'generated', -- 'generated', 'custom_edited'
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY `idx_user_drop_plan` (`user_id`, `drop_id`),
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
  FOREIGN KEY (`drop_id`) REFERENCES `drops`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 7. Plan Items
CREATE TABLE IF NOT EXISTS `plan_items` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `plan_id` INT NOT NULL,
  `item_id` INT NOT NULL,
  `tier` VARCHAR(50) NOT NULL, -- 'easy', 'stretch', 'wildcard'
  `state` VARCHAR(50) NOT NULL DEFAULT 'not_started', -- 'not_started', 'opened', 'marked_read'
  `opened_at` DATETIME,
  `completed_at` DATETIME,
  FOREIGN KEY (`plan_id`) REFERENCES `plans`(`id`) ON DELETE CASCADE,
  FOREIGN KEY (`item_id`) REFERENCES `items`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 8. Card Notes
CREATE TABLE IF NOT EXISTS `notes` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT NOT NULL,
  `item_id` INT NOT NULL,
  `quote` TEXT,
  `text` TEXT NOT NULL,
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
  FOREIGN KEY (`item_id`) REFERENCES `items`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 9. Weekly Reflections
CREATE TABLE IF NOT EXISTS `reflections` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT NOT NULL,
  `drop_id` INT NOT NULL,
  `prompt` VARCHAR(255) NOT NULL DEFAULT 'What changed your mind this week?',
  `text` TEXT NOT NULL,
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY `idx_user_drop_reflection` (`user_id`, `drop_id`),
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
  FOREIGN KEY (`drop_id`) REFERENCES `drops`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 10. Session RSVPs
CREATE TABLE IF NOT EXISTS `rsvps` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT NOT NULL,
  `drop_id` INT NOT NULL,
  `status` VARCHAR(50) NOT NULL DEFAULT 'attending', -- 'attending', 'declined', 'attended'
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  UNIQUE KEY `idx_user_drop_rsvp` (`user_id`, `drop_id`),
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
  FOREIGN KEY (`drop_id`) REFERENCES `drops`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 11. WhatsApp Groups
CREATE TABLE IF NOT EXISTS `whatsapp_groups` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `name` VARCHAR(255) NOT NULL,
  `link` VARCHAR(500) NOT NULL,
  `category` VARCHAR(100) NOT NULL DEFAULT 'general',
  `tags` TEXT,
  `is_active` INT NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 12. Nudge Templates
CREATE TABLE IF NOT EXISTS `nudge_templates` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `name` VARCHAR(255) NOT NULL,
  `channel` VARCHAR(50) NOT NULL DEFAULT 'push',
  `subject` VARCHAR(255) NOT NULL,
  `body` TEXT NOT NULL,
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 13. Nudge Campaigns
CREATE TABLE IF NOT EXISTS `nudge_campaigns` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `template_id` INT NOT NULL,
  `segment` VARCHAR(100) NOT NULL DEFAULT 'all',
  `status` VARCHAR(50) NOT NULL DEFAULT 'draft',
  `scheduled_at` DATETIME,
  `sent_at` DATETIME,
  FOREIGN KEY (`template_id`) REFERENCES `nudge_templates`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 14. Nudge Sends Log
CREATE TABLE IF NOT EXISTS `nudge_sends` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `campaign_id` INT,
  `user_id` INT NOT NULL,
  `channel` VARCHAR(50) NOT NULL,
  `title` VARCHAR(255) NOT NULL,
  `body` TEXT NOT NULL,
  `status` VARCHAR(50) NOT NULL DEFAULT 'sent',
  `sent_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 15. Subtle Promo Cards
CREATE TABLE IF NOT EXISTS `promo_cards` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `title` VARCHAR(255) NOT NULL,
  `content` TEXT NOT NULL,
  `cta_text` VARCHAR(100) NOT NULL DEFAULT 'Explore',
  `cta_link` VARCHAR(500) NOT NULL,
  `frequency_cap_days` INT NOT NULL DEFAULT 14,
  `is_active` INT NOT NULL DEFAULT 1,
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 16. Events Log (SSE Concurrency)
CREATE TABLE IF NOT EXISTS `events_log` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `event_type` VARCHAR(100) NOT NULL,
  `payload` TEXT NOT NULL,
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 17. Section 4: Orders (Cashfree Payment Records)
CREATE TABLE IF NOT EXISTS `orders` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `order_id` VARCHAR(100) NOT NULL UNIQUE,
  `user_id` INT NOT NULL,
  `drop_id` INT NOT NULL,
  `order_amount` DECIMAL(10, 2) NOT NULL,
  `order_currency` VARCHAR(10) NOT NULL DEFAULT 'INR',
  `order_status` VARCHAR(50) NOT NULL DEFAULT 'PENDING',
  `payment_session_id` VARCHAR(255),
  `cf_payment_id` VARCHAR(100),
  `customer_phone` VARCHAR(20) NOT NULL,
  `customer_email` VARCHAR(255) NOT NULL,
  `customer_name` VARCHAR(255) NOT NULL,
  `seat_number` VARCHAR(50),
  `refund_id` VARCHAR(100),
  `refund_amount` DECIMAL(10, 2),
  `refund_status` VARCHAR(50),
  `payment_method` VARCHAR(50),
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  `paid_at` DATETIME,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
  FOREIGN KEY (`drop_id`) REFERENCES `drops`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 18. Section 4: Audit Log (Financial & Access Audit Trail)
CREATE TABLE IF NOT EXISTS `audit_log` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `action` VARCHAR(100) NOT NULL,
  `actor_type` VARCHAR(50) NOT NULL DEFAULT 'user',
  `actor_id` INT,
  `entity_type` VARCHAR(50),
  `entity_id` VARCHAR(100),
  `payload` TEXT,
  `ip_address` VARCHAR(45),
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 19. Section 4: Webhook Events (Idempotency deduplication)
CREATE TABLE IF NOT EXISTS `webhook_events` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `event_id` VARCHAR(150) NOT NULL UNIQUE,
  `event_type` VARCHAR(100) NOT NULL,
  `payload` TEXT NOT NULL,
  `processed_at` DATETIME DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- =========================================================================
-- SEED DATA
-- =========================================================================

-- Seed Users
INSERT INTO `users` (`id`, `email`, `name`, `role`, `notification_preferences`, `created_at`) VALUES
(1, 'ayush@restlessdreamers.in', 'Ayush', 'admin', '{"push":true,"email":true}', NOW()),
(2, 'curator@restlessdreamers.in', 'Maya Sharma', 'curator', '{"push":true,"email":true}', NOW()),
(3, 'arjun@college.edu', 'Arjun Mehta', 'member', '{"push":true,"email":true}', NOW()),
(4, 'riya@college.edu', 'Riya Sen', 'member', '{"push":true,"email":true}', NOW())
ON DUPLICATE KEY UPDATE `name` = VALUES(`name`);

-- Seed Profiles
INSERT INTO `profiles` (`user_id`, `interests`, `weekly_minutes`, `reading_depth`) VALUES
(1, '["psychology","culture","science","marketing","economics"]', 60, 'standard'),
(2, '["culture","marketing"]', 45, 'standard'),
(3, '["psychology","science"]', 90, 'deep'),
(4, '["culture","economics"]', 30, 'skim')
ON DUPLICATE KEY UPDATE `interests` = VALUES(`interests`);

-- Seed Drop
INSERT INTO `drops` (`id`, `week_slug`, `title`, `phenomenon`, `primer`, `session_time`, `session_link`, `status`, `is_paid`, `price_inr`, `capacity`) VALUES
(1, 'week-45-loneliness-economy', 'The Loneliness Economy', 'Hyper-Individualism & The Loneliness Economy',
'We have engineered a world where you never have to ask a neighbor for sugar, an acquaintance for a ride, or a friend for company. But independence without inter-dependence comes with a devastating invoice: we are paying subscription fees to rent back the human belonging we traded away. This weekend, we dismantle the cultural, psychological, and economic engine of modern isolation.',
'2026-11-08 18:00:00', 'https://meet.google.com/rd-weekend-live', 'published', 1, 499.00, 30)
ON DUPLICATE KEY UPDATE `title` = VALUES(`title`);

-- Seed Items (Content Pool)
INSERT INTO `items` (`id`, `url`, `canonical_url`, `title`, `description`, `source`, `favicon`, `type`, `tier`, `discipline`, `time_estimate`, `why_note`, `status`) VALUES
(1, 'https://aeon.co/essays/why-solitude-is-not-the-same-as-loneliness', 'https://aeon.co/essays/why-solitude-is-not-the-same-as-loneliness', 'Why solitude is not the same as loneliness', 'An exploration of how solitude was historically an active state of creative and spiritual vitality, whereas modern loneliness is a passive deprivation of communal trust.', 'Aeon Magazine', 'https://www.google.com/s2/favicons?domain=aeon.co', 'article', 'easy', 'psychology', 8, 'Essential foundation: separates voluntary solitude from the pain of structural isolation.', 'published'),
(2, 'https://theatlantic.com/family/archive/2021/04/the-death-of-the-third-place/618582/', 'https://theatlantic.com/family/archive/2021/04/the-death-of-the-third-place/618582/', 'The Death of the Third Place and the Atomized City', 'Ray Oldenburg coined third places as anchors of civil society. Today, suburban sprawl and private clubs have privatized leisure, leaving young people nowhere to linger without paying.', 'The Atlantic', 'https://www.google.com/s2/favicons?domain=theatlantic.com', 'article', 'stretch', 'culture', 14, 'Structural analysis of urban space and the slow erosion of free association.', 'published'),
(3, 'https://nature.com/articles/s41586-022-04533-z', 'https://nature.com/articles/s41586-022-04533-z', 'The Dopamine Loop of Parasocial Intimacy', 'Neuroimaging reveals that parasocial media interactions activate surrogate connection circuits without triggering oxytocin release, generating an insatiable consumption loop.', 'Restless Science Lab', 'https://www.google.com/s2/favicons?domain=nature.com', 'video', 'easy', 'science', 12, 'Scientific deconstruction of why 6 hours of scrolling streamers leaves you lonelier than zero.', 'published'),
(4, 'https://hbr.org/2023/02/the-marketization-of-belonging', 'https://hbr.org/2023/02/the-marketization-of-belonging', 'The Marketization of Belonging: Monetizing the Void', 'From co-living subscriptions at $3,500/mo to rent-a-friend services in Tokyo, venture capital has turned the emotional void of atomization into the next high-margin recurring SaaS.', 'Harvard Business Review', 'https://www.google.com/s2/favicons?domain=hbr.org', 'paper', 'stretch', 'marketing', 18, 'The business model behind loneliness: why tech monopolies profit when communities fragment.', 'published'),
(5, 'https://ourworldindata.org/social-connections', 'https://ourworldindata.org/social-connections', 'Time Spent Alone: A 50-Year Demographic Shift', 'Empirical time-use survey data across 40 countries tracing the steady steep climb of hours spent alone from adolescence through middle age between 1975 and 2025.', 'Our World in Data', 'https://www.google.com/s2/favicons?domain=ourworldindata.org', 'article', 'wildcard', 'economics', 11, 'Cold, incontrovertible macroeconomic data proving the loneliness epidemic is not in your head.', 'published')
ON DUPLICATE KEY UPDATE `title` = VALUES(`title`);

-- Seed Drop Items (5 Lenses)
INSERT INTO `drop_items` (`drop_id`, `item_id`, `lens`, `display_order`) VALUES
(1, 1, 'Psychology', 1),
(1, 2, 'Culture', 2),
(1, 3, 'Science', 3),
(1, 4, 'Marketing', 4),
(1, 5, 'Economics', 5)
ON DUPLICATE KEY UPDATE `lens` = VALUES(`lens`);

-- Seed WhatsApp Groups
INSERT INTO `whatsapp_groups` (`id`, `name`, `link`, `category`, `tags`, `is_active`) VALUES
(1, 'Weekend Sessions 045 • All Scholars', 'https://chat.whatsapp.com/sample-session-045', 'general', '["session","general"]', 1),
(2, 'The Loneliness Economy • Deep Salon', 'https://chat.whatsapp.com/sample-loneliness-deep', 'interest', '["psychology","economics"]', 1),
(3, 'Restless Fellows Cohort 2026', 'https://chat.whatsapp.com/sample-fellows-2026', 'cohort', '["fellows","alumni"]', 1)
ON DUPLICATE KEY UPDATE `name` = VALUES(`name`);

-- Seed Nudge Templates
INSERT INTO `nudge_templates` (`id`, `name`, `channel`, `subject`, `body`) VALUES
(1, 'Thursday Flight Plan Reminder', 'push', 'your flight plan is ready', 'three curated perspectives on the loneliness economy await your reading.'),
(2, 'Saturday Evening Salon Warning', 'push', 'salon countdown: t-minus 24h', 'sunday 18:00 ist. review your notes and quotes before scholars gather.'),
(3, 'Sunday Manifest Call', 'push', 'manifest boarding call: 18:00 ist', 'the phenomenon salon starts in 15 minutes. tap to join via google meet.')
ON DUPLICATE KEY UPDATE `name` = VALUES(`name`);

-- Seed Sample Paid Orders
INSERT INTO `orders` (`order_id`, `user_id`, `drop_id`, `order_amount`, `order_status`, `customer_phone`, `customer_email`, `customer_name`, `seat_number`, `paid_at`) VALUES
('RD_SESSION_1_user3_1730700000', 3, 1, 499.00, 'PAID', '9876543210', 'arjun@college.edu', 'Arjun Mehta', 'RD-045-29', '2026-11-04 10:15:00'),
('RD_SESSION_1_user4_1730701000', 4, 1, 499.00, 'PAID', '9812345678', 'riya@college.edu', 'Riya Sen', 'RD-045-28', '2026-11-04 11:20:00')
ON DUPLICATE KEY UPDATE `order_status` = VALUES(`order_status`);

-- Seed Sample RSVPs
INSERT INTO `rsvps` (`user_id`, `drop_id`, `status`, `created_at`) VALUES
(3, 1, 'attending', NOW()),
(4, 1, 'attending', NOW())
ON DUPLICATE KEY UPDATE `status` = VALUES(`status`);

SET FOREIGN_KEY_CHECKS = 1;

