-- MySQL dump 10.13  Distrib 8.0.40, for Linux (x86_64)
--
-- Host: localhost    Database: happy_paradise
-- ------------------------------------------------------
-- Server version	8.0.40-0ubuntu0.22.04.1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!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 */;

--
-- Table structure for table `events_attributes`
--

DROP TABLE IF EXISTS `events_attributes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `events_attributes` (
  `uid` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event_uid` bigint unsigned NOT NULL,
  `attribute_id` int unsigned NOT NULL COMMENT '一個活動下的各屬性編號',
  `attribute_currency` varchar(4) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '屬性幣別，未設置則使用活動預設幣別，若都為空則自動設置為USD',
  `attribute_is_rebate` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否歸類為返水',
  `attribute_type` enum('deposit','withdraw','wager','win','lose','others') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'deposit' COMMENT '屬性的條件種類',
  `attribute_subtype` enum('>','>=','=','<=','<') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '>' COMMENT '屬性的條件判斷符號',
  `attribute_value` double NOT NULL DEFAULT '0' COMMENT '屬性的條件基準值',
  `rewards_uid` bigint unsigned DEFAULT NULL,
  `attribute_value_basis` enum('single','cumulative') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'cumulative' COMMENT '活動參與金額判斷是以單次或累積金額',
  `attribute_single_amount_target` enum('max','min','latest','earliest') COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '單次金額目標為最大、最小、最晚或最早',
  `attribute_start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '屬性開始時間',
  `attribute_end_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '屬性結束時間',
  `attribute_is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '屬性的即時狀態，若在活動期間須暫停此屬性，可關閉此狀態',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`uid`),
  UNIQUE KEY `attribute` (`event_uid`,`attribute_id`),
  KEY `events_attributes_attribute_currency_index` (`attribute_currency`),
  KEY `condition` (`attribute_type`,`attribute_subtype`,`attribute_value`),
  KEY `events_attributes_attribute_start_time_index` (`attribute_start_time`),
  KEY `events_attributes_attribute_end_time_index` (`attribute_end_time`),
  KEY `events_attributes_attribute_is_active_index` (`attribute_is_active`),
  KEY `events_attributes_rewards_uid_foreign` (`rewards_uid`),
  CONSTRAINT `events_attributes_attribute_currency_foreign` FOREIGN KEY (`attribute_currency`) REFERENCES `currencies` (`currency_code`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `events_attributes_event_uid_foreign` FOREIGN KEY (`event_uid`) REFERENCES `events_list` (`uid`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `events_attributes_rewards_uid_foreign` FOREIGN KEY (`rewards_uid`) REFERENCES `rewards` (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `events_attributes`
--

LOCK TABLES `events_attributes` WRITE;
/*!40000 ALTER TABLE `events_attributes` DISABLE KEYS */;
REPLACE INTO `events_attributes` VALUES (9,9,1,'TWD',0,'deposit','>=',1000,2,'single','earliest','2025-01-11 00:00:00','2025-12-31 00:00:00',1,'2025-01-10 10:10:28','2025-01-14 08:26:27'),(10,10,1,'TWD',0,'wager','>=',0,3,'single','min','2025-01-11 00:00:00','2026-01-01 00:00:00',1,'2025-01-10 10:21:50','2025-01-13 09:57:33'),(11,11,1,'TWD',0,'deposit','>=',1,4,'cumulative',NULL,'2025-01-11 00:00:00','2030-01-31 00:00:00',1,'2025-01-10 14:16:29','2025-01-14 01:56:03');
/*!40000 ALTER TABLE `events_attributes` ENABLE KEYS */;
UNLOCK TABLES;
/*!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 */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2025-01-20 19:22:30
