CREATE DATABASE  IF NOT EXISTS `board_log` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */;
USE `board_log`;
--
-- Host: localhost    Database: board_log
-- ------------------------------------------------------

 SET NAMES utf8 ;

--
-- Table structure for table `pg_badugi_detail`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_badugi_detail` (
  `pkey` varchar(2) NOT NULL COMMENT '일 파티션키',
  `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '로그시간',
  `room_id` varchar(40) NOT NULL DEFAULT '0' COMMENT '룸 고유번호',
  `room_play_count` int(11) NOT NULL DEFAULT '0',
  `json_data` json NOT NULL,
  KEY `create_date` (`create_date`),
  KEY `room_id` (`room_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='바둑이 상세보기'
/*!50500 PARTITION BY LIST  COLUMNS(pkey)
(PARTITION pg_badugi_detail_01 VALUES IN ('01') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_02 VALUES IN ('02') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_03 VALUES IN ('03') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_04 VALUES IN ('04') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_05 VALUES IN ('05') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_06 VALUES IN ('06') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_07 VALUES IN ('07') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_08 VALUES IN ('08') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_09 VALUES IN ('09') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_10 VALUES IN ('10') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_11 VALUES IN ('11') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_12 VALUES IN ('12') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_13 VALUES IN ('13') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_14 VALUES IN ('14') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_15 VALUES IN ('15') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_16 VALUES IN ('16') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_17 VALUES IN ('17') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_18 VALUES IN ('18') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_19 VALUES IN ('19') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_20 VALUES IN ('20') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_21 VALUES IN ('21') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_22 VALUES IN ('22') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_23 VALUES IN ('23') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_24 VALUES IN ('24') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_25 VALUES IN ('25') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_26 VALUES IN ('26') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_27 VALUES IN ('27') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_28 VALUES IN ('28') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_29 VALUES IN ('29') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_30 VALUES IN ('30') ENGINE = InnoDB,
 PARTITION pg_badugi_detail_31 VALUES IN ('31') ENGINE = InnoDB) */;

--
-- Table structure for table `pg_badugi_record`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_badugi_record` (
  `pkey` varchar(2) NOT NULL COMMENT '일 파티션키',
  `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '로그시간',
  `room_id` varchar(40) NOT NULL DEFAULT '0' COMMENT '룸 고유번호',
  `mem_ids` varchar(100) NOT NULL DEFAULT '',
  `json_data` json NOT NULL,
  KEY `create_date` (`create_date`),
  KEY `room_id` (`room_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='포인트 획득/소모 로그'
/*!50500 PARTITION BY LIST  COLUMNS(pkey)
(PARTITION pg_badugi_record_01 VALUES IN ('01') ENGINE = InnoDB,
 PARTITION pg_badugi_record_02 VALUES IN ('02') ENGINE = InnoDB,
 PARTITION pg_badugi_record_03 VALUES IN ('03') ENGINE = InnoDB,
 PARTITION pg_badugi_record_04 VALUES IN ('04') ENGINE = InnoDB,
 PARTITION pg_badugi_record_05 VALUES IN ('05') ENGINE = InnoDB,
 PARTITION pg_badugi_record_06 VALUES IN ('06') ENGINE = InnoDB,
 PARTITION pg_badugi_record_07 VALUES IN ('07') ENGINE = InnoDB,
 PARTITION pg_badugi_record_08 VALUES IN ('08') ENGINE = InnoDB,
 PARTITION pg_badugi_record_09 VALUES IN ('09') ENGINE = InnoDB,
 PARTITION pg_badugi_record_10 VALUES IN ('10') ENGINE = InnoDB,
 PARTITION pg_badugi_record_11 VALUES IN ('11') ENGINE = InnoDB,
 PARTITION pg_badugi_record_12 VALUES IN ('12') ENGINE = InnoDB,
 PARTITION pg_badugi_record_13 VALUES IN ('13') ENGINE = InnoDB,
 PARTITION pg_badugi_record_14 VALUES IN ('14') ENGINE = InnoDB,
 PARTITION pg_badugi_record_15 VALUES IN ('15') ENGINE = InnoDB,
 PARTITION pg_badugi_record_16 VALUES IN ('16') ENGINE = InnoDB,
 PARTITION pg_badugi_record_17 VALUES IN ('17') ENGINE = InnoDB,
 PARTITION pg_badugi_record_18 VALUES IN ('18') ENGINE = InnoDB,
 PARTITION pg_badugi_record_19 VALUES IN ('19') ENGINE = InnoDB,
 PARTITION pg_badugi_record_20 VALUES IN ('20') ENGINE = InnoDB,
 PARTITION pg_badugi_record_21 VALUES IN ('21') ENGINE = InnoDB,
 PARTITION pg_badugi_record_22 VALUES IN ('22') ENGINE = InnoDB,
 PARTITION pg_badugi_record_23 VALUES IN ('23') ENGINE = InnoDB,
 PARTITION pg_badugi_record_24 VALUES IN ('24') ENGINE = InnoDB,
 PARTITION pg_badugi_record_25 VALUES IN ('25') ENGINE = InnoDB,
 PARTITION pg_badugi_record_26 VALUES IN ('26') ENGINE = InnoDB,
 PARTITION pg_badugi_record_27 VALUES IN ('27') ENGINE = InnoDB,
 PARTITION pg_badugi_record_28 VALUES IN ('28') ENGINE = InnoDB,
 PARTITION pg_badugi_record_29 VALUES IN ('29') ENGINE = InnoDB,
 PARTITION pg_badugi_record_30 VALUES IN ('30') ENGINE = InnoDB,
 PARTITION pg_badugi_record_31 VALUES IN ('31') ENGINE = InnoDB) */;

--
-- Table structure for table `pg_common_log`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_common_log` (
  `pkey` varchar(2) NOT NULL COMMENT '일 파티션키',
  `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '로그시간',
  `mem_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '행동',
  `type` int(11) NOT NULL DEFAULT '0',
  `action_type` int(11) NOT NULL DEFAULT '0' COMMENT '행동',
  `json_data` json NOT NULL,
  PRIMARY KEY (`pkey`),
  KEY `create_date` (`create_date`),
  KEY `mem_id` (`mem_id`),
  KEY `action_type` (`action_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
/*!50500 PARTITION BY LIST  COLUMNS(pkey)
(PARTITION pg_common_log_01 VALUES IN ('01') ENGINE = InnoDB,
 PARTITION pg_common_log_02 VALUES IN ('02') ENGINE = InnoDB,
 PARTITION pg_common_log_03 VALUES IN ('03') ENGINE = InnoDB,
 PARTITION pg_common_log_04 VALUES IN ('04') ENGINE = InnoDB,
 PARTITION pg_common_log_05 VALUES IN ('05') ENGINE = InnoDB,
 PARTITION pg_common_log_06 VALUES IN ('06') ENGINE = InnoDB,
 PARTITION pg_common_log_07 VALUES IN ('07') ENGINE = InnoDB,
 PARTITION pg_common_log_08 VALUES IN ('08') ENGINE = InnoDB,
 PARTITION pg_common_log_09 VALUES IN ('09') ENGINE = InnoDB,
 PARTITION pg_common_log_10 VALUES IN ('10') ENGINE = InnoDB,
 PARTITION pg_common_log_11 VALUES IN ('11') ENGINE = InnoDB,
 PARTITION pg_common_log_12 VALUES IN ('12') ENGINE = InnoDB,
 PARTITION pg_common_log_13 VALUES IN ('13') ENGINE = InnoDB,
 PARTITION pg_common_log_14 VALUES IN ('14') ENGINE = InnoDB,
 PARTITION pg_common_log_15 VALUES IN ('15') ENGINE = InnoDB,
 PARTITION pg_common_log_16 VALUES IN ('16') ENGINE = InnoDB,
 PARTITION pg_common_log_17 VALUES IN ('17') ENGINE = InnoDB,
 PARTITION pg_common_log_18 VALUES IN ('18') ENGINE = InnoDB,
 PARTITION pg_common_log_19 VALUES IN ('19') ENGINE = InnoDB,
 PARTITION pg_common_log_20 VALUES IN ('20') ENGINE = InnoDB,
 PARTITION pg_common_log_21 VALUES IN ('21') ENGINE = InnoDB,
 PARTITION pg_common_log_22 VALUES IN ('22') ENGINE = InnoDB,
 PARTITION pg_common_log_23 VALUES IN ('23') ENGINE = InnoDB,
 PARTITION pg_common_log_24 VALUES IN ('24') ENGINE = InnoDB,
 PARTITION pg_common_log_25 VALUES IN ('25') ENGINE = InnoDB,
 PARTITION pg_common_log_26 VALUES IN ('26') ENGINE = InnoDB,
 PARTITION pg_common_log_27 VALUES IN ('27') ENGINE = InnoDB,
 PARTITION pg_common_log_28 VALUES IN ('28') ENGINE = InnoDB,
 PARTITION pg_common_log_29 VALUES IN ('29') ENGINE = InnoDB,
 PARTITION pg_common_log_30 VALUES IN ('30') ENGINE = InnoDB,
 PARTITION pg_common_log_31 VALUES IN ('31') ENGINE = InnoDB) */;

--
-- Table structure for table `pg_goods_log`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_goods_log` (
  `pkey` varchar(2) NOT NULL COMMENT '일 파티션키',
  `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '로그시간',
  `user_id` int(11) NOT NULL,
  `action_type` int(11) NOT NULL DEFAULT '0' COMMENT '행동',
  `json_data` json NOT NULL,
  KEY `create_date` (`create_date`),
  KEY `action_type` (`action_type`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='재화 획득/소모 로그'
/*!50500 PARTITION BY LIST  COLUMNS(pkey)
(PARTITION pg_goods_log_01 VALUES IN ('01') ENGINE = InnoDB,
 PARTITION pg_goods_log_02 VALUES IN ('02') ENGINE = InnoDB,
 PARTITION pg_goods_log_03 VALUES IN ('03') ENGINE = InnoDB,
 PARTITION pg_goods_log_04 VALUES IN ('04') ENGINE = InnoDB,
 PARTITION pg_goods_log_05 VALUES IN ('05') ENGINE = InnoDB,
 PARTITION pg_goods_log_06 VALUES IN ('06') ENGINE = InnoDB,
 PARTITION pg_goods_log_07 VALUES IN ('07') ENGINE = InnoDB,
 PARTITION pg_goods_log_08 VALUES IN ('08') ENGINE = InnoDB,
 PARTITION pg_goods_log_09 VALUES IN ('09') ENGINE = InnoDB,
 PARTITION pg_goods_log_10 VALUES IN ('10') ENGINE = InnoDB,
 PARTITION pg_goods_log_11 VALUES IN ('11') ENGINE = InnoDB,
 PARTITION pg_goods_log_12 VALUES IN ('12') ENGINE = InnoDB,
 PARTITION pg_goods_log_13 VALUES IN ('13') ENGINE = InnoDB,
 PARTITION pg_goods_log_14 VALUES IN ('14') ENGINE = InnoDB,
 PARTITION pg_goods_log_15 VALUES IN ('15') ENGINE = InnoDB,
 PARTITION pg_goods_log_16 VALUES IN ('16') ENGINE = InnoDB,
 PARTITION pg_goods_log_17 VALUES IN ('17') ENGINE = InnoDB,
 PARTITION pg_goods_log_18 VALUES IN ('18') ENGINE = InnoDB,
 PARTITION pg_goods_log_19 VALUES IN ('19') ENGINE = InnoDB,
 PARTITION pg_goods_log_20 VALUES IN ('20') ENGINE = InnoDB,
 PARTITION pg_goods_log_21 VALUES IN ('21') ENGINE = InnoDB,
 PARTITION pg_goods_log_22 VALUES IN ('22') ENGINE = InnoDB,
 PARTITION pg_goods_log_23 VALUES IN ('23') ENGINE = InnoDB,
 PARTITION pg_goods_log_24 VALUES IN ('24') ENGINE = InnoDB,
 PARTITION pg_goods_log_25 VALUES IN ('25') ENGINE = InnoDB,
 PARTITION pg_goods_log_26 VALUES IN ('26') ENGINE = InnoDB,
 PARTITION pg_goods_log_27 VALUES IN ('27') ENGINE = InnoDB,
 PARTITION pg_goods_log_28 VALUES IN ('28') ENGINE = InnoDB,
 PARTITION pg_goods_log_29 VALUES IN ('29') ENGINE = InnoDB,
 PARTITION pg_goods_log_30 VALUES IN ('30') ENGINE = InnoDB,
 PARTITION pg_goods_log_31 VALUES IN ('31') ENGINE = InnoDB) */;

--
-- Table structure for table `pg_history_log`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_history_log` (
  `pkey` varchar(2) NOT NULL COMMENT '일 파티션키',
  `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '로그시간',
  `mem_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '유저번호',
  `action_type` int(11) NOT NULL DEFAULT '0' COMMENT '행동',
  `json_data` json NOT NULL,
  PRIMARY KEY (`pkey`,`create_date`,`mem_id`),
  KEY `create_date` (`create_date`),
  KEY `mem_id` (`mem_id`),
  KEY `action_type` (`action_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
/*!50500 PARTITION BY LIST  COLUMNS(pkey)
(PARTITION pg_history_log_01 VALUES IN ('01') ENGINE = InnoDB,
 PARTITION pg_history_log_02 VALUES IN ('02') ENGINE = InnoDB,
 PARTITION pg_history_log_03 VALUES IN ('03') ENGINE = InnoDB,
 PARTITION pg_history_log_04 VALUES IN ('04') ENGINE = InnoDB,
 PARTITION pg_history_log_05 VALUES IN ('05') ENGINE = InnoDB,
 PARTITION pg_history_log_06 VALUES IN ('06') ENGINE = InnoDB,
 PARTITION pg_history_log_07 VALUES IN ('07') ENGINE = InnoDB,
 PARTITION pg_history_log_08 VALUES IN ('08') ENGINE = InnoDB,
 PARTITION pg_history_log_09 VALUES IN ('09') ENGINE = InnoDB,
 PARTITION pg_history_log_10 VALUES IN ('10') ENGINE = InnoDB,
 PARTITION pg_history_log_11 VALUES IN ('11') ENGINE = InnoDB,
 PARTITION pg_history_log_12 VALUES IN ('12') ENGINE = InnoDB,
 PARTITION pg_history_log_13 VALUES IN ('13') ENGINE = InnoDB,
 PARTITION pg_history_log_14 VALUES IN ('14') ENGINE = InnoDB,
 PARTITION pg_history_log_15 VALUES IN ('15') ENGINE = InnoDB,
 PARTITION pg_history_log_16 VALUES IN ('16') ENGINE = InnoDB,
 PARTITION pg_history_log_17 VALUES IN ('17') ENGINE = InnoDB,
 PARTITION pg_history_log_18 VALUES IN ('18') ENGINE = InnoDB,
 PARTITION pg_history_log_19 VALUES IN ('19') ENGINE = InnoDB,
 PARTITION pg_history_log_20 VALUES IN ('20') ENGINE = InnoDB,
 PARTITION pg_history_log_21 VALUES IN ('21') ENGINE = InnoDB,
 PARTITION pg_history_log_22 VALUES IN ('22') ENGINE = InnoDB,
 PARTITION pg_history_log_23 VALUES IN ('23') ENGINE = InnoDB,
 PARTITION pg_history_log_24 VALUES IN ('24') ENGINE = InnoDB,
 PARTITION pg_history_log_25 VALUES IN ('25') ENGINE = InnoDB,
 PARTITION pg_history_log_26 VALUES IN ('26') ENGINE = InnoDB,
 PARTITION pg_history_log_27 VALUES IN ('27') ENGINE = InnoDB,
 PARTITION pg_history_log_28 VALUES IN ('28') ENGINE = InnoDB,
 PARTITION pg_history_log_29 VALUES IN ('29') ENGINE = InnoDB,
 PARTITION pg_history_log_30 VALUES IN ('30') ENGINE = InnoDB,
 PARTITION pg_history_log_31 VALUES IN ('31') ENGINE = InnoDB) */;

--
-- Table structure for table `pg_matgo_detail`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_matgo_detail` (
  `pkey` varchar(2) NOT NULL COMMENT '일 파티션키',
  `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '로그시간',
  `room_id` varchar(40) NOT NULL DEFAULT '0' COMMENT '룸 고유번호',
  `mem_ids` varchar(100) NOT NULL DEFAULT '',
  `json_data` json NOT NULL,
  PRIMARY KEY (`pkey`),
  KEY `create_date` (`create_date`),
  KEY `room_id` (`room_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='맞고 상세보기'
/*!50500 PARTITION BY LIST  COLUMNS(pkey)
(PARTITION pg_matgo_detail_01 VALUES IN ('01') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_02 VALUES IN ('02') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_03 VALUES IN ('03') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_04 VALUES IN ('04') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_05 VALUES IN ('05') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_06 VALUES IN ('06') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_07 VALUES IN ('07') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_08 VALUES IN ('08') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_09 VALUES IN ('09') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_10 VALUES IN ('10') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_11 VALUES IN ('11') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_12 VALUES IN ('12') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_13 VALUES IN ('13') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_14 VALUES IN ('14') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_15 VALUES IN ('15') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_16 VALUES IN ('16') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_17 VALUES IN ('17') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_18 VALUES IN ('18') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_19 VALUES IN ('19') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_20 VALUES IN ('20') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_21 VALUES IN ('21') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_22 VALUES IN ('22') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_23 VALUES IN ('23') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_24 VALUES IN ('24') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_25 VALUES IN ('25') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_26 VALUES IN ('26') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_27 VALUES IN ('27') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_28 VALUES IN ('28') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_29 VALUES IN ('29') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_30 VALUES IN ('30') ENGINE = InnoDB,
 PARTITION pg_matgo_detail_31 VALUES IN ('31') ENGINE = InnoDB) */;

--
-- Table structure for table `pg_matgo_record`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_matgo_record` (
  `pkey` varchar(2) NOT NULL COMMENT '일 파티션키',
  `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '로그시간',
  `room_id` varchar(40) NOT NULL DEFAULT '0' COMMENT '룸 고유번호',
  `mem_ids` varchar(100) NOT NULL DEFAULT '',
  `json_data` json NOT NULL,
  PRIMARY KEY (`pkey`,`create_date`,`room_id`),
  KEY `create_date` (`create_date`),
  KEY `room_id` (`room_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='맞고 전적'
/*!50500 PARTITION BY LIST  COLUMNS(pkey)
(PARTITION pg_matgo_record_01 VALUES IN ('01') ENGINE = InnoDB,
 PARTITION pg_matgo_record_02 VALUES IN ('02') ENGINE = InnoDB,
 PARTITION pg_matgo_record_03 VALUES IN ('03') ENGINE = InnoDB,
 PARTITION pg_matgo_record_04 VALUES IN ('04') ENGINE = InnoDB,
 PARTITION pg_matgo_record_05 VALUES IN ('05') ENGINE = InnoDB,
 PARTITION pg_matgo_record_06 VALUES IN ('06') ENGINE = InnoDB,
 PARTITION pg_matgo_record_07 VALUES IN ('07') ENGINE = InnoDB,
 PARTITION pg_matgo_record_08 VALUES IN ('08') ENGINE = InnoDB,
 PARTITION pg_matgo_record_09 VALUES IN ('09') ENGINE = InnoDB,
 PARTITION pg_matgo_record_10 VALUES IN ('10') ENGINE = InnoDB,
 PARTITION pg_matgo_record_11 VALUES IN ('11') ENGINE = InnoDB,
 PARTITION pg_matgo_record_12 VALUES IN ('12') ENGINE = InnoDB,
 PARTITION pg_matgo_record_13 VALUES IN ('13') ENGINE = InnoDB,
 PARTITION pg_matgo_record_14 VALUES IN ('14') ENGINE = InnoDB,
 PARTITION pg_matgo_record_15 VALUES IN ('15') ENGINE = InnoDB,
 PARTITION pg_matgo_record_16 VALUES IN ('16') ENGINE = InnoDB,
 PARTITION pg_matgo_record_17 VALUES IN ('17') ENGINE = InnoDB,
 PARTITION pg_matgo_record_18 VALUES IN ('18') ENGINE = InnoDB,
 PARTITION pg_matgo_record_19 VALUES IN ('19') ENGINE = InnoDB,
 PARTITION pg_matgo_record_20 VALUES IN ('20') ENGINE = InnoDB,
 PARTITION pg_matgo_record_21 VALUES IN ('21') ENGINE = InnoDB,
 PARTITION pg_matgo_record_22 VALUES IN ('22') ENGINE = InnoDB,
 PARTITION pg_matgo_record_23 VALUES IN ('23') ENGINE = InnoDB,
 PARTITION pg_matgo_record_24 VALUES IN ('24') ENGINE = InnoDB,
 PARTITION pg_matgo_record_25 VALUES IN ('25') ENGINE = InnoDB,
 PARTITION pg_matgo_record_26 VALUES IN ('26') ENGINE = InnoDB,
 PARTITION pg_matgo_record_27 VALUES IN ('27') ENGINE = InnoDB,
 PARTITION pg_matgo_record_28 VALUES IN ('28') ENGINE = InnoDB,
 PARTITION pg_matgo_record_29 VALUES IN ('29') ENGINE = InnoDB,
 PARTITION pg_matgo_record_30 VALUES IN ('30') ENGINE = InnoDB,
 PARTITION pg_matgo_record_31 VALUES IN ('31') ENGINE = InnoDB) */;

--
-- Table structure for table `pg_member_coffers_log`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_member_coffers_log` (
  `mem_id` text,
  `mem_coffers` int(11) DEFAULT NULL,
  `mem_datetime` text,
  `mem_is_input` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `pg_member_reward_log`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_member_reward_log` (
  `mem_id` text,
  `mem_reward_money` text,
  `mem_addDate` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `pg_profit_increased_log`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_profit_increased_log` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `shop_idx` int(11) DEFAULT '0',
  `shop_name` varchar(100) DEFAULT '',
  `start_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `end_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `start_increased_money` int(11) DEFAULT '0' COMMENT '증액셋팅값',
  `end_increased_money` int(11) DEFAULT '0' COMMENT '증액셋팅값',
  PRIMARY KEY (`idx`),
  KEY `shop_idx` (`shop_idx`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8 COMMENT='수익 서비스 로그';

--
-- Table structure for table `pg_shop_log`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_shop_log` (
  `pkey` varchar(2) NOT NULL COMMENT '일 파티션키',
  `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '로그시간',
  `shop_idx` int(11) NOT NULL DEFAULT '0' COMMENT '매장번호',
  `shop_name` varchar(40) NOT NULL DEFAULT '0' COMMENT '매장명',
  `deposit` int(11) NOT NULL DEFAULT '0',
  `withdrawal` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`pkey`),
  KEY `create_date` (`create_date`),
  KEY `shop_idx` (`shop_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='매장별 정산'
/*!50500 PARTITION BY LIST  COLUMNS(pkey)
(PARTITION pg_shop_logl_01 VALUES IN ('01') ENGINE = InnoDB,
 PARTITION pg_shop_logl_02 VALUES IN ('02') ENGINE = InnoDB,
 PARTITION pg_shop_logl_03 VALUES IN ('03') ENGINE = InnoDB,
 PARTITION pg_shop_logl_04 VALUES IN ('04') ENGINE = InnoDB,
 PARTITION pg_shop_logl_05 VALUES IN ('05') ENGINE = InnoDB,
 PARTITION pg_shop_logl_06 VALUES IN ('06') ENGINE = InnoDB,
 PARTITION pg_shop_logl_07 VALUES IN ('07') ENGINE = InnoDB,
 PARTITION pg_shop_logl_08 VALUES IN ('08') ENGINE = InnoDB,
 PARTITION pg_shop_logl_09 VALUES IN ('09') ENGINE = InnoDB,
 PARTITION pg_shop_logl_10 VALUES IN ('10') ENGINE = InnoDB,
 PARTITION pg_shop_logl_11 VALUES IN ('11') ENGINE = InnoDB,
 PARTITION pg_shop_logl_12 VALUES IN ('12') ENGINE = InnoDB,
 PARTITION pg_shop_logl_13 VALUES IN ('13') ENGINE = InnoDB,
 PARTITION pg_shop_logl_14 VALUES IN ('14') ENGINE = InnoDB,
 PARTITION pg_shop_logl_15 VALUES IN ('15') ENGINE = InnoDB,
 PARTITION pg_shop_logl_16 VALUES IN ('16') ENGINE = InnoDB,
 PARTITION pg_shop_logl_17 VALUES IN ('17') ENGINE = InnoDB,
 PARTITION pg_shop_logl_18 VALUES IN ('18') ENGINE = InnoDB,
 PARTITION pg_shop_logl_19 VALUES IN ('19') ENGINE = InnoDB,
 PARTITION pg_shop_logl_20 VALUES IN ('20') ENGINE = InnoDB,
 PARTITION pg_shop_logl_21 VALUES IN ('21') ENGINE = InnoDB,
 PARTITION pg_shop_logl_22 VALUES IN ('22') ENGINE = InnoDB,
 PARTITION pg_shop_logl_23 VALUES IN ('23') ENGINE = InnoDB,
 PARTITION pg_shop_logl_24 VALUES IN ('24') ENGINE = InnoDB,
 PARTITION pg_shop_logl_25 VALUES IN ('25') ENGINE = InnoDB,
 PARTITION pg_shop_logl_26 VALUES IN ('26') ENGINE = InnoDB,
 PARTITION pg_shop_logl_27 VALUES IN ('27') ENGINE = InnoDB,
 PARTITION pg_shop_logl_28 VALUES IN ('28') ENGINE = InnoDB,
 PARTITION pg_shop_logl_29 VALUES IN ('29') ENGINE = InnoDB,
 PARTITION pg_shop_logl_30 VALUES IN ('30') ENGINE = InnoDB,
 PARTITION pg_shop_logl_31 VALUES IN ('31') ENGINE = InnoDB) */;

--
-- Table structure for table `pg_user_increased_log`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_user_increased_log` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `shop_idx` int(11) DEFAULT '0',
  `shop_name` varchar(100) DEFAULT '',
  `mem_idx` int(11) DEFAULT '0',
  `mem_userid` varchar(100) DEFAULT '',
  `mem_nickname` varchar(100) DEFAULT '',
  `start_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `end_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `get_increaset_money` int(11) DEFAULT '0' COMMENT '증액수익금',
  `log_idx` int(11) DEFAULT '0' COMMENT '로그순서 구분값(pg_profit_increased_log의 idx대응)',
  PRIMARY KEY (`idx`),
  KEY `shop_idx` (`shop_idx`),
  KEY `mem_idx` (`mem_idx`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8 COMMENT='vip 서비스 로그';

--
-- Table structure for table `pg_vip_increased_log`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `pg_vip_increased_log` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `shop_idx` int(11) DEFAULT '0',
  `shop_name` varchar(100) DEFAULT '',
  `mem_idx` int(11) DEFAULT '0',
  `mem_userid` varchar(100) DEFAULT '',
  `mem_nickname` varchar(100) DEFAULT '',
  `start_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `end_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `service_money` int(11) DEFAULT '0' COMMENT 'vip 서비스금액',
  `start_money` int(11) DEFAULT '0' COMMENT '시작 유저보유금',
  `start_reward` int(11) DEFAULT '0' COMMENT '시작 유저리워드',
  `end_money` int(11) DEFAULT '0' COMMENT '종료 유저보유금',
  `end_reward` int(11) DEFAULT '0' COMMENT '종료 유저리워드',
  PRIMARY KEY (`idx`),
  KEY `shop_idx` (`shop_idx`),
  KEY `mem_idx` (`mem_idx`)
) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8 COMMENT='vip 서비스 로그';

--
-- Dumping events for database 'board_log'
--

--
-- Dumping routines for database 'board_log'
--
/*!50003 DROP PROCEDURE IF EXISTS `spGetCoffersLogData` */;
ALTER DATABASE `board_log` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
CREATE PROCEDURE `spGetCoffersLogData`(IN i_n_id int(11))
BEGIN
declare ret_n_mem_reward datetime default DATE_ADD(now(), INTERVAL -3 DAY);
select * from board_log.`pg_goods_log`    
where ret_n_mem_reward <= create_date     
    and (action_type = 2000 or action_type = 2001) 
    and user_id = i_n_id
   
order by create_date desc;    
END ;;
DELIMITER ;
ALTER DATABASE `board_log` CHARACTER SET utf8 COLLATE utf8_bin ;
/*!50003 DROP PROCEDURE IF EXISTS `spGetRewardLogData` */;
ALTER DATABASE `board_log` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
CREATE PROCEDURE `spGetRewardLogData`(IN n_id int(11))
BEGIN
    declare ret_n_mem_reward datetime default DATE_ADD(now(), INTERVAL -3 DAY);
	select * from board_log.`pg_goods_log`    
	where ret_n_mem_reward <= create_date     
		-- and action_type in (2002,2010 )
        and action_type in (2002)
		and user_id = n_id
	order by create_date desc limit 10;     
END ;;
DELIMITER ;
ALTER DATABASE `board_log` CHARACTER SET utf8 COLLATE utf8_bin ;
/*!50003 DROP PROCEDURE IF EXISTS `spInsertLogData` */;
ALTER DATABASE `board_log` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
CREATE PROCEDURE `spInsertLogData`(
in str_key varchar(2)
,in str_date varchar(24)
,in str_room_id varchar(40)
,in str_mem_ids varchar(100)
, in str_jason json
)
BEGIN
    insert into pg_matgo_record values(str_key,str_date,str_room_id,str_mem_ids,str_jason);
END ;;
DELIMITER ;
ALTER DATABASE `board_log` CHARACTER SET utf8 COLLATE utf8_bin ;
/*!50003 DROP PROCEDURE IF EXISTS `spInsertProfitIncreasedLog` */;
ALTER DATABASE `board_log` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
CREATE PROCEDURE `spInsertProfitIncreasedLog`(
in n_type int
,in n_shop_idx int
,in n_increased_money int
)
BEGIN
    declare ret_n_idx int default 0;
    
    if n_type = 0 then
		insert into pg_profit_increased_log(shop_idx, start_date, start_increased_money)
		values (n_shop_idx, now(), n_increased_money);
        
        call spInsertUserIncreasedLog(n_type, n_shop_idx, 0, '', '', n_increased_money);
	else
		select idx into ret_n_idx from pg_profit_increased_log where shop_idx = n_shop_idx order by idx desc limit 1;
        update pg_profit_increased_log set end_date = now(), end_increased_money = n_increased_money where idx = ret_n_idx;
        
        call spInsertUserIncreasedLog(n_type, n_shop_idx, 0, '', '', n_increased_money);
	end if;
END ;;
DELIMITER ;
ALTER DATABASE `board_log` CHARACTER SET utf8 COLLATE utf8_bin ;
/*!50003 DROP PROCEDURE IF EXISTS `spInsertUserIncreasedLog` */;
DELIMITER ;;
CREATE PROCEDURE `spInsertUserIncreasedLog`(
in n_type int
,in n_shop_idx int
,in n_mem_idx int
,in n_mem_userid varchar(100) 
,in n_mem_nickname varchar(100) 
,in n_get_increaset_money int
)
BEGIN
    declare ret_n_idx int default 0;
    declare ret_n_log_idx int default 0;
    declare ret_sz_shop_name varchar(100) default '';
    declare ret_dt_start_date datetime;
    
    if n_type = 0 then
		select idx into ret_n_idx from pg_profit_increased_log where shop_idx = n_shop_idx order by idx desc limit 1;
        
        /*insert into pg_user_increased_log(shop_idx, mem_idx, mem_userid, mem_nickname, start_date, get_increaset_money, log_idx)
		select parents, mem_id, mem_userid, mem_nickname, now(), 0, ret_n_idx from board_game.pg_member join board_game.pg_member_reward on pg_member.mem_id = pg_member_reward.mem_n_id 
			where mem_level = 1 and parents = n_shop_idx and mem_user_type = 3;*/
	elseif n_type = 1 then
		select idx, start_date into ret_n_idx, ret_dt_start_date from pg_profit_increased_log where shop_idx = n_shop_idx order by idx desc limit 1;
        /*update board_log.pg_user_increased_log join board_game.pg_member on pg_user_increased_log.mem_idx = pg_member.mem_id set end_date = now(), get_increaset_money = mem_n_total_temp_play_sum_money_profit where mem_idx in (
			select mem_id from board_game.pg_member join board_game.pg_member_reward on pg_member.mem_id = pg_member_reward.mem_n_id where mem_level = 1 and parents = n_shop_idx and mem_user_type = 4
			) and log_idx = ret_n_idx;*/
            
		insert into board_log.pg_user_increased_log(shop_idx, mem_idx, mem_userid, mem_nickname, start_date, end_date, get_increaset_money, log_idx)
		select parents, mem_id, mem_userid, mem_nickname, ret_dt_start_date, now(), mem_n_total_temp_play_sum_money_profit, ret_n_idx 
		from board_game.pg_member join board_game.pg_member_reward on pg_member.mem_id = pg_member_reward.mem_n_id where mem_level = 1 and parents = n_shop_idx and mem_user_type = 4
			and mem_n_total_temp_play_sum_money_profit <> 0;
	else
		select idx into ret_n_log_idx from pg_user_increased_log where mem_idx = n_mem_idx order by idx desc limit 1;
        update pg_user_increased_log set end_date = now(), get_increaset_money = get_increaset_money + n_get_increaset_money where mem_idx = n_mem_idx and idx = ret_n_log_idx;
	end if;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `spInsertVipIncreasedLog` */;
ALTER DATABASE `board_log` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
CREATE PROCEDURE `spInsertVipIncreasedLog`(
in n_type int
,in n_shop_idx int
,in n_mem_idx int
,in n_mem_userid varchar(100) 
,in n_mem_nickname varchar(100) 
,in n_service_money int
,in n_money int
,in n_reward int
)
BEGIN
	declare ret_sz_mem_userid varchar(100) default '';
    declare ret_sz_mem_nickname varchar(100) default '';
    declare ret_n_idx int default 0;
    declare ret_sz_shop_name varchar(100) default '';
    
    if n_type = 0 then
		insert into pg_vip_increased_log(shop_idx, mem_idx, mem_userid, mem_nickname, start_date, service_money, start_money, start_reward, end_money, end_reward)
		values (n_shop_idx, n_mem_idx, n_mem_userid, n_mem_nickname, now(), n_service_money, n_money, n_reward, 0, 0);
	else
		select idx into ret_n_idx from pg_vip_increased_log where mem_idx = n_mem_idx order by idx desc limit 1;
        update pg_vip_increased_log set end_date = now(), end_money = n_money, end_reward = n_reward where idx = ret_n_idx;
	end if;
END ;;
DELIMITER ;
ALTER DATABASE `board_log` CHARACTER SET utf8 COLLATE utf8_bin ;
/*!50003 DROP PROCEDURE IF EXISTS `spUpdateLog` */;
ALTER DATABASE `board_log` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
CREATE PROCEDURE `spUpdateLog`(IN IaccountID VARCHAR(100)
    , IN nAmount bigint
    , IN nInsertValue smallint 
    , IN nLogType smallint 
    )
BEGIN
  declare ret_code int(11) default 1;  
  
	case nLogType
		when 0 then	
			INSERT INTO `board_log`.`pg_member_coffers_log`(`mem_id`, `mem_coffers`, `mem_datetime`, `mem_is_input`) values (IaccountID, nAmount, now(), nInsertValue);            
		when 1 then
			INSERT INTO `board_log`.`pg_member_reward_log`(`mem_id`, `mem_reward_money`, `mem_addDate`) values (IaccountID, nAmount, now());
		else
			set ret_code = -17;
	end case;
    
    select ret_code;  
END ;;
DELIMITER ;
ALTER DATABASE `board_log` CHARACTER SET utf8 COLLATE utf8_bin ;


