-- 시스템 테이블
CREATE TABLE SYSTEM (
    NO      INT NOT NULL AUTO_INCREMENT,
    REG     VARCHAR(1) DEFAULT 'N',
    LOGIN   VARCHAR(1) DEFAULT 'N',
    NOTICE  VARCHAR(256) DEFAULT '',
    CRT_DATE DATETIME,
    MDF_DATE DATETIME,

    PRIMARY KEY (NO)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8;

-- 회원 테이블
CREATE TABLE `member` (
	`NO` INT(11) NOT NULL AUTO_INCREMENT,
	`ID` VARCHAR(64) NOT NULL,
	`EMAIL` VARCHAR(64) NULL DEFAULT NULL,
	`PW` CHAR(128) NOT NULL,
	`salt1` CHAR(16) NOT NULL,
	`salt2` CHAR(16) NULL DEFAULT NULL,
	`NAME` VARCHAR(64) NOT NULL,
	`IP` VARCHAR(64) NULL DEFAULT '',
	`PICTURE` VARCHAR(64) NULL DEFAULT '',
	`IMGSVR` INT(1) NULL DEFAULT '0',
	`CONMSG` VARCHAR(256) NULL DEFAULT '',
	`GRADE` INT(1) NULL DEFAULT '1',
	`REG_NUM` INT(3) NULL DEFAULT '0',
	`REG_DATE` DATETIME NULL DEFAULT NULL,
	`BLOCK_NUM` INT(3) NULL DEFAULT '0',
	`BLOCK_DATE` DATETIME NULL DEFAULT NULL,
	`QUIT` VARCHAR(1) NULL DEFAULT '',
	PRIMARY KEY (`NO`),
	UNIQUE INDEX `ID` (`ID`),
	UNIQUE INDEX `EMAIL` (`EMAIL`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;


-- 인증 테이블

CREATE TABLE EMAIL (
    NO      INT NOT NULL AUTO_INCREMENT,
    EMAIL   VARCHAR(64) NOT NULL,
    CODE    VARCHAR(6)  NOT NULL,
    VERIFIED INT(1) DEFAULT 0,
    REG_DATE DATETIME,
    VRF_DATE DATETIME,

    PRIMARY KEY (NO)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8;


CREATE TABLE `member_log` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`member_no` INT(11) NOT NULL,
	`date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
	`action_type` ENUM('reg','try_login','login','logout','oauth','make_general','access_server') NOT NULL,
	`action` TEXT NULL DEFAULT NULL COMMENT 'JSON',
	PRIMARY KEY (`id`),
	INDEX `action` (`member_no`, `action_type`, `date`),
	INDEX `member` (`member_no`, `date`)
)
ENGINE=MyISAM;