-- Flow C (abandoned cart): the incentives table (same as migration 2026_10_26_000008; safe to run twice).
-- The wording of C1-C3 is added by migration 2026_10_26_000009 or `php artisan push-flows:seed-templates`.
CREATE TABLE IF NOT EXISTS `push_flow_incentives` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `kind` varchar(20) NOT NULL,
  `run_id` bigint unsigned DEFAULT NULL,
  `message_id` bigint unsigned DEFAULT NULL,
  `coupon_id` bigint unsigned DEFAULT NULL,
  `coupon_code` varchar(40) DEFAULT NULL,
  `issued_at` timestamp NULL DEFAULT NULL,
  `expires_at` timestamp NULL DEFAULT NULL,
  `expired_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `push_incentives_message_unique` (`message_id`),
  KEY `push_incentives_user_issued_index` (`user_id`,`issued_at`),
  KEY `push_incentives_expires_index` (`expires_at`),
  KEY `push_incentives_coupon_index` (`coupon_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
