--
-- Host: 127.0.0.1    Database: moree
-- ------------------------------------------------------



--
-- Host: 127.0.0.1    Database: moree
-- ------------------------------------------------------


--
-- Table structure for table `company_login_logs`
--

CREATE TABLE `company_login_logs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint(20) unsigned NOT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `browser` varchar(120) DEFAULT NULL,
  `os` varchar(120) DEFAULT NULL,
  `result` varchar(20) NOT NULL COMMENT 'success|failed',
  `logged_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_cll_company` (`company_id`,`logged_at`),
  CONSTRAINT `fk_cll_company` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=244 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `company_login_logs`
--
-- WHERE:  company_id=1019

INSERT INTO `company_login_logs` VALUES (214,1019,'211.197.16.113','Chrome/149.0.0.0','Windows NT 10.0; Win64; x64','success','2026-06-11 09:18:34'),(220,1019,'211.197.16.113','Chrome/149.0.0.0','Windows NT 10.0; Win64; x64','success','2026-06-11 12:54:18'),(234,1019,'211.197.16.113','Chrome/149.0.0.0','Windows NT 10.0; Win64; x64','success','2026-06-11 17:06:55'),(239,1019,'211.197.16.113','Chrome/149.0.0.0','Windows NT 10.0; Win64; x64','success','2026-06-12 13:10:59');


--
-- Host: 127.0.0.1    Database: moree
-- ------------------------------------------------------



--
-- Host: 127.0.0.1    Database: moree
-- ------------------------------------------------------


--
-- Table structure for table `coupon_usages`
--

CREATE TABLE `coupon_usages` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `coupon_id` bigint(20) unsigned NOT NULL,
  `company_id` bigint(20) unsigned NOT NULL,
  `payment_id` bigint(20) unsigned DEFAULT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'available' COMMENT 'available|used|expired',
  `discount_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `registered_at` datetime NOT NULL DEFAULT current_timestamp() COMMENT '사용자 등록 시각',
  `used_at` datetime DEFAULT NULL COMMENT '결제 적용 시각',
  `expired_at` datetime DEFAULT NULL COMMENT '기간만료 처리 시각',
  PRIMARY KEY (`id`),
  KEY `idx_cu_coupon` (`coupon_id`,`registered_at`),
  KEY `idx_cu_company` (`company_id`,`registered_at`),
  KEY `fk_cu_payment` (`payment_id`),
  KEY `idx_cu_company_status` (`company_id`,`status`),
  CONSTRAINT `fk_cu_company` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_cu_coupon` FOREIGN KEY (`coupon_id`) REFERENCES `coupons` (`id`),
  CONSTRAINT `fk_cu_payment` FOREIGN KEY (`payment_id`) REFERENCES `payments` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `coupon_usages`
--
-- WHERE:  company_id=1019

INSERT INTO `coupon_usages` VALUES (26,8,1019,NULL,'available',0.00,'2026-06-11 20:12:35',NULL,'2026-06-30 23:59:59');


