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


--
-- Table structure for table `companies`
--

CREATE TABLE `companies` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` varchar(16) NOT NULL COMMENT '로그인 아이디 (4~16자 영숫자, 소문자)',
  `password_hash` varchar(255) NOT NULL COMMENT 'Argon2id 해시',
  `company_name` varchar(160) NOT NULL COMMENT '법인단체 명',
  `representative_name` varchar(60) DEFAULT NULL,
  `site_domain` varchar(80) DEFAULT NULL COMMENT 'ERP 테넌트 서브도메인(erp_module/site_config.site_domain과 매칭)',
  `site_domain_suffix` varchar(40) NOT NULL DEFAULT '.acux.store' COMMENT '사이트 도메인 접미사 — 기존은 .acux.store, 신규는 .mo-ree.com',
  `acux_company_id` int(11) DEFAULT NULL COMMENT 'agent.companies.id 매핑 (acuxmsg)',
  `business_no` varchar(10) NOT NULL COMMENT '사업자등록번호 10자리 (하이픈 제외)',
  `email` varchar(160) NOT NULL,
  `phone_mobile` varchar(20) NOT NULL COMMENT '휴대폰',
  `phone_office` varchar(20) DEFAULT NULL COMMENT '일반전화 (선택)',
  `address` varchar(300) NOT NULL COMMENT '사업장 소재지',
  `address_detail` varchar(200) DEFAULT NULL,
  `agree_service` tinyint(1) NOT NULL DEFAULT 0,
  `agree_privacy` tinyint(1) NOT NULL DEFAULT 0,
  `agree_marketing` tinyint(1) NOT NULL DEFAULT 0,
  `agree_marketing_at` datetime DEFAULT NULL,
  `status` varchar(30) NOT NULL DEFAULT 'active' COMMENT 'active|paused|suspended|terminated',
  `last_login_at` datetime DEFAULT NULL,
  `first_erp_visit_at` datetime DEFAULT NULL COMMENT 'mypage index에서 ERP 첫 진입 시각',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `deleted_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_user_id` (`user_id`),
  UNIQUE KEY `uk_business_no` (`business_no`),
  UNIQUE KEY `uk_email` (`email`),
  UNIQUE KEY `site_domain` (`site_domain`),
  KEY `idx_status` (`status`),
  KEY `idx_companies_acux` (`acux_company_id`),
  KEY `idx_companies_deleted_created` (`deleted_at`,`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=1022 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `companies`
--
-- WHERE:  id IN (1012,1021)

INSERT INTO `companies` VALUES (1012,'test00','$argon2id$v=19$m=65536,t=4,p=1$Yy8wTUs5L3QzMGwyeEVMUA$cFIKJIgv7DHm8t2yPM2iSy2wccSbx/l0Bt4Ae42wVM8','모리테스트','이서현','mo-test00','.mo-ree.com',NULL,'7828800172','lhyeonnit@gmail.com','010-3045-5558',NULL,'서울 금천구 가산디지털1로 1 1동 123호','1동 123호',1,1,0,NULL,'active','2026-06-12 17:22:55','2026-06-11 12:23:29','2026-06-01 15:40:49','2026-06-12 17:22:55',NULL),(1021,'beentest','$argon2id$v=19$m=65536,t=4,p=1$dndVMlZJdzYzYVFpWC8vbw$LvNYZPL8cEe1cC2lbXG/tcfaNITKeKrc+8gwPWT5vqY','been_test22','한상빈','been','.mo-ree.com',NULL,'1444334521','gswx31@gmail.com','010-9635-8823',NULL,'전남 구례군 구례읍 5일시장작은길 33 342','342',1,1,1,'2026-06-12 14:58:47','active','2026-06-12 17:27:08','2026-06-12 14:59:37','2026-06-12 14:58:47','2026-06-12 17:27:52',NULL);


