create or replace table mydb_deploy.account
(
	idx int not null
		primary key,
	account_code varchar(45) null,
	account_name varchar(45) null,
	bank_id int default 0 null
)
comment '금융기관 기본 코드 테이블 ';

create or replace table mydb_deploy.account_level_list
(
	idx int auto_increment
		primary key,
	level int null comment '전용 계좌 레벨 (member 레벨) ',
	account_name varchar(45) null,
	account_bank varchar(45) null comment '은행명',
	account_number varchar(45) null comment '계좌 번호 ',
	display_account_bank varchar(45) default '' null,
	bank_id int default 0 null,
	create_dt datetime default current_timestamp() null,
	update_dt datetime default current_timestamp() null on update current_timestamp(),
	constraint UQ_ACCOUNT_LEVEL_01
		unique (level)
)
comment '회원 레벨 별 전용 계좌 목록 ';

create or replace table mydb_deploy.X_average_dividend_provider
(
	sports_id int not null
		primary key,
	provider varchar(128) not null comment '제외할 프로바이더'
)
comment '평균베당 제외할 프로바이더';

create or replace table mydb_deploy.X_base_rule
(
	idx int auto_increment
		primary key,
	bet_type int default 0 null comment '1 : 프리매치 2: 실시간 3 : 파워볼,4파워사다리 5: 키노사다리 6 : 가상축구 ',
	id int default 0 not null,
	name varchar(32) null comment '종목명',
	result_process varchar(16) not null comment '결과처리',
	end_time int unsigned default 0 not null comment '마감시간',
	max_dividend int unsigned default 0 not null comment '최대배당',
	betting_regulation text null comment '배팅규제'
);

create or replace index idx_bet_type
	on mydb_deploy.X_base_rule (bet_type);

create or replace table mydb_deploy.X_base_rule_2
(
	idx int auto_increment
		primary key,
	type varchar(16) null comment '구분',
	contents text null comment '내용'
);

create or replace table mydb_deploy.X_category_rule
(
	category int unsigned not null comment '카테고리 (1: 실시간, 2: 스포츠, 3: 미니게임)',
	sub_category int unsigned not null comment '하위 카테고리 (코드 참조)',
	title varchar(255) not null comment '제목',
	content mediumtext not null comment '내용',
	create_dt datetime default current_timestamp() not null comment '생성일',
	update_dt datetime null comment '수정일',
	primary key (category, sub_category)
)
comment '종목별 룰';

create or replace table mydb_deploy.X_charge_event
(
	level int(11) unsigned not null comment '레벨 (1 ~ 10)'
		primary key,
	bonus int(11) unsigned default 1000000 not null comment '보너스(%)',
	max_bonus int default 0 not null
)
comment '돌발충전 이벤트';

create or replace table mydb_deploy.X_charge_type
(
	level int not null
		primary key,
	charge_type int not null,
	name varchar(45) null
)
comment '레벨별 충전방식';

create or replace table mydb_deploy.X_dividend_policy
(
	`rank` int(11) unsigned not null comment '등급 (1 ~ N)',
	type tinyint(1) unsigned not null comment '타입 (1: 프리매치, 2: 실시간)',
	amount int(11) unsigned default 1000000 not null comment '등급별 배당 금액',
	create_dt datetime default current_timestamp() not null comment '생성일',
	update_dt datetime null comment '수정일',
	primary key (`rank`, type)
)
comment '배당 금액 정책 테이블';

create or replace index idx_bet_type
	on mydb_deploy.X_dividend_policy (type);

create or replace index idx_rank
	on mydb_deploy.X_dividend_policy (`rank`);

create or replace table mydb_deploy.events
(
	idx int auto_increment
		primary key,
	name varchar(45) default '' null,
	thumbnail varchar(1024) default '' null,
	detail text default '' null,
	status tinyint default 1 null comment '0-미사용, 1-사용',
	del_flag tinyint default 0 null comment '0-존재, 1-삭제됨',
	create_dt datetime default current_timestamp() null,
	update_dt datetime default current_timestamp() null on update current_timestamp(),
	delete_dt datetime default current_timestamp() null
);

create or replace index thumbnail
	on mydb_deploy.events (thumbnail);

create or replace table mydb_deploy.X_fixtures_bet_sum
(
	member_idx int not null,
	fixture_id int default 0 not null,
	bet_type int default 0 not null comment '1 : 스포츠 2 : 실시간 ',
	sum_bet_money bigint default 0 null,
	primary key (fixture_id, bet_type, member_idx)
)
comment '유저들의 경기별 배팅금액을 누적관리하는 테이블이다 스포츠,실시간 각각 관리된다.';

create or replace table mydb_deploy.X_fixtures_markets_bet_sum
(
	member_idx int not null,
	fixture_id int default 0 not null,
	markets_id int default 0 not null,
	bet_type int default 0 not null comment '1 : 스포츠 2 : 실시간 ',
	sum_bet_money bigint default 0 null,
	update_dt datetime default current_timestamp() not null comment '수정일',
	primary key (fixture_id, bet_type, member_idx)
)
comment '유저들의 경기별, 마켓별 배팅금액을 누적관리하는 테이블이다 스포츠,실시간 각각 관리된다.';

create or replace table mydb_deploy.X_help
(
	idx int auto_increment
		primary key,
	member_idx int null,
	admin_idx int null,
	title varchar(45) null,
	contents varchar(45) null,
	status varchar(45) default '대기' null comment '‘대기’, ‘완료’',
	is_delete varchar(45) null,
	create_datetime datetime null
);

create or replace table mydb_deploy.X_join_message
(
	a_id varchar(45) not null comment '작성자'
		primary key,
	title varchar(100) null,
	contents text null,
	update_dt datetime default current_timestamp() null
)
comment '가입메세지';

create or replace table mydb_deploy.X_leagues_image_name
(
	idx int auto_increment
		primary key,
	name varchar(64) null comment '이미지명'
);

create or replace table mydb_deploy.X_level_bet_policy
(
	level int(11) unsigned not null comment '레벨 (1 ~ 10)',
	bet_type tinyint(1) unsigned not null comment '타입 (1: 프리매치, 2: 실시간)',
	amount int(11) unsigned default 1000000 not null comment '레벨별 베팅 한도 금액',
	create_dt datetime default current_timestamp() not null comment '생성일',
	update_dt datetime null comment '수정일',
	primary key (level, bet_type)
)
comment '레벨별 베팅 금액 테이블';

create or replace table mydb_deploy.X_lsports_bet
(
	bet_id bigint unsigned not null comment '배팅 아이디',
	fixture_id bigint default 0 not null comment 'lsports_fixtures.fixture_id 참조 ',
	bet_type int not null comment '0:기타, 1:스포츠, 2:실시간',
	markets_id int default 0 not null comment 'lsports_markets.id ',
	markets_name varchar(45) null,
	real_bet_price decimal(7,2) null comment '실제로 보여지는 배팅값 ',
	providers_id int null comment '공급자 아이디. 공급자는 해당 배팅 정보를 불러오는 원본 정보 제공 업체이다. (대포적으로 bet365)',
	providers_name varchar(45) null comment '공급자 이름',
	providers_last_update datetime null comment '공급자 정보 마지막으로 업데이트 한 시간 _ UTC ',
	bet_name varchar(45) null comment '배팅 이름, market_id comment 에 없는 목록은 하지 않는다.  [1:승,첫득점팀 X:무 2:패,첫득점팀, No Goal:첫득점팀 Over:오버 Under: 언더 12:더블찬스 승패 X1:더블찬스 승무 X2:더블찬스 무패 No:양팀득점실패 Yes:양팀득점성공 X/X,1/X,2/X:전반전 및 풀타임 Even:홀 Odd:짝 0-0,1-0,0-1…: 정확한스코어]',
	bet_status int default 1 not null comment '배팅 상태 [1:open(배팅가능) 2:Suspended(배팅중단) 3:Settled(결과완료)]',
	bet_line varchar(45) null comment 'Line (마켓이 핸디캡/언더오버인 경우  해당값으로 정산 결과를 반영, front view 에서도 일부 값을 표현하는데 사용)',
	bet_base_line varchar(45) null comment 'base_Line (마켓이 핸디캡/언더오버인 경우  해당값으로 정산 결과를 반영, front view 에서도 일부 값을 표현하는데 사용)',
	bet_settlement int null,
	bet_start_price decimal(7,2) null comment '시작 배팅 값 ',
	bet_price decimal(7,2) null comment '현재 배팅 값 ',
	bet_last_update datetime null comment '마지막 배팅 업데이트 시간 _ UTC ',
	admin_bet_status enum('ON', 'OFF') default 'ON' null comment 'ON, OFF',
	create_dt datetime default current_timestamp() null comment 'KST ',
	update_dt datetime default current_timestamp() null on update current_timestamp() comment 'KST',
	delete_dt datetime null comment 'KST ',
	result_p1 int null,
	result_p2 int null,
	result_2_p1 int null,
	result_2_p2 int null,
	fixture_start_date datetime not null,
	bet_price_hit decimal(7,2) default 0.00 null,
	update_data datetime default current_timestamp() null,
	primary key (bet_id, bet_type)
)
engine=MEMORY;

create or replace index idx_fix_id
	on mydb_deploy.X_lsports_bet (fixture_id);

create or replace index idx_mk_id
	on mydb_deploy.X_lsports_bet (markets_id);

create or replace index idx_sports
	on mydb_deploy.X_lsports_bet (bet_type, bet_status, admin_bet_status);

create or replace index idx_st_dt
	on mydb_deploy.X_lsports_bet (fixture_start_date);

create or replace table mydb_deploy.X_lsports_bet_InnoDB
(
	bet_id bigint unsigned not null comment '배팅 아이디',
	fixture_id bigint default 0 not null comment 'lsports_fixtures.fixture_id 참조 ',
	bet_type int not null comment '0:기타, 1:스포츠, 2:실시간',
	markets_id int default 0 not null comment 'lsports_markets.id ',
	markets_name varchar(45) null,
	real_bet_price decimal(7,2) null comment '실제로 보여지는 배팅값 ',
	providers_id int null comment '공급자 아이디. 공급자는 해당 배팅 정보를 불러오는 원본 정보 제공 업체이다. (대포적으로 bet365)',
	providers_name varchar(45) null comment '공급자 이름',
	providers_last_update datetime null comment '공급자 정보 마지막으로 업데이트 한 시간 _ UTC ',
	bet_name varchar(45) null comment '배팅 이름, market_id comment 에 없는 목록은 하지 않는다.  [1:승,첫득점팀 X:무 2:패,첫득점팀, No Goal:첫득점팀 Over:오버 Under: 언더 12:더블찬스 승패 X1:더블찬스 승무 X2:더블찬스 무패 No:양팀득점실패 Yes:양팀득점성공 X/X,1/X,2/X:전반전 및 풀타임 Even:홀 Odd:짝 0-0,1-0,0-1…: 정확한스코어]',
	bet_status int default 1 not null comment '배팅 상태 [1:open(배팅가능) 2:Suspended(배팅중단) 3:Settled(결과완료)]',
	bet_line varchar(45) null comment 'Line (마켓이 핸디캡/언더오버인 경우  해당값으로 정산 결과를 반영, front view 에서도 일부 값을 표현하는데 사용)',
	bet_base_line varchar(45) null comment 'base_Line (마켓이 핸디캡/언더오버인 경우  해당값으로 정산 결과를 반영, front view 에서도 일부 값을 표현하는데 사용)',
	bet_settlement int null,
	bet_start_price decimal(7,2) null comment '시작 배팅 값 ',
	bet_price decimal(7,2) null comment '현재 배팅 값 ',
	bet_last_update datetime null comment '마지막 배팅 업데이트 시간 _ UTC ',
	admin_bet_status enum('ON', 'OFF') default 'ON' null comment 'ON, OFF',
	create_dt datetime default current_timestamp() null comment 'KST ',
	update_dt datetime default current_timestamp() null on update current_timestamp() comment 'KST',
	delete_dt datetime null comment 'KST ',
	result_p1 int null,
	result_p2 int null,
	result_2_p1 int null,
	result_2_p2 int null,
	fixture_start_date datetime not null,
	bet_price_hit decimal(7,2) default 0.00 null,
	update_data datetime default current_timestamp() null,
	primary key (bet_id, bet_type)
);

create or replace index idx_fix
	on mydb_deploy.X_lsports_bet_InnoDB (fixture_id);

create or replace index idx_mk_id
	on mydb_deploy.X_lsports_bet_InnoDB (markets_id);

create or replace index idx_sports
	on mydb_deploy.X_lsports_bet_InnoDB (bet_type, bet_status, admin_bet_status);

create or replace index idx_st_dt
	on mydb_deploy.X_lsports_bet_InnoDB (fixture_start_date);

create or replace table mydb_deploy.X_lsports_bookmaker
(
	id int not null
		primary key,
	name varchar(45) null,
	lang varchar(4) null,
	is_use tinyint default 0 null,
	create_dt datetime default current_timestamp() null,
	update_dt datetime default current_timestamp() null on update current_timestamp(),
	delete_dt datetime null
);

create or replace index idx_is_use
	on mydb_deploy.X_lsports_bookmaker (is_use);

create or replace table mydb_deploy.X_lsports_fixtures
(
	fixture_id int not null comment 'lsports api 에서 조회한 fixtures_id 값 ',
	bet_type int default 0 not null comment '0:기타, 1:스포츠, 2:실시간',
	fixture_sport_id int not null comment 'lsports_sports 테이블 참조 ',
	fixture_location_id int not null comment 'lsports_location 테이블 참조 ',
	fixture_league_id int not null comment 'lsports_league 테이블 참조 ',
	fixture_start_date datetime not null comment '경기 시작 시간  _ KST 기준 ',
	fixture_status varchar(2) not null comment '현재 경기 상태
1	Not started yet
2	In progress
3	Finished
4	Cancelled
5	Postponed
6	Interrupted
7	Abandoned
8	Coverage lost
9	About to start	',
	fixture_participants_1_id int null,
	fixture_participants_2_id int null,
	livescore mediumtext null,
	create_dt datetime default current_timestamp() null comment 'KST',
	update_dt datetime default current_timestamp() null on update current_timestamp() comment 'KST',
	live_results_p1 int null,
	live_results_p2 int null,
	m_live_results_p1 int null,
	m_live_results_p2 int null,
	admin_bet_status enum('ON', 'OFF', 'RETRY') default 'ON' null,
	display_status int default 1 null comment '1. 베팅가능=> status 1,9 => 픽스처정보에서 배팅가능은 경기시간에서 -1440분을 뺀 시간부터 -1분까지의 경기
2. 베팅마감 =>status 2,5,6,7,8  => 경기시간에서 59초를 뺀 경기
3. 종료 => status 3,4  =>  결과처리된 경기 또는 4,5,6,7이 들어올시 (경기상세정보에서 적특표기색상으로 해주세요 노란색)
',
	break_dt datetime null,
	primary key (fixture_id, bet_type)
);

create or replace index idx_bet_type
	on mydb_deploy.X_lsports_fixtures (bet_type);

create or replace index idx_dis
	on mydb_deploy.X_lsports_fixtures (display_status);

create or replace index idx_fix_id
	on mydb_deploy.X_lsports_fixtures (fixture_id);

create or replace index idx_std
	on mydb_deploy.X_lsports_fixtures (fixture_start_date);

create or replace index idx_type
	on mydb_deploy.X_lsports_fixtures (bet_type, fixture_start_date);

create or replace table mydb_deploy.X_lsports_fixtures_innoDB
(
	fixture_id int not null comment 'lsports api 에서 조회한 fixtures_id 값 ',
	bet_type int default 0 not null comment '0:기타, 1:스포츠, 2:실시간',
	fixture_sport_id int not null comment 'lsports_sports 테이블 참조 ',
	fixture_sport_name varchar(45) null comment 'lsports_sports 테이블 참조 ',
	fixture_location_id int not null comment 'lsports_location 테이블 참조 ',
	fixture_location_name varchar(45) null comment 'lsports_location 테이블 참조 ',
	fixture_league_id int not null comment 'lsports_league 테이블 참조 ',
	fixture_league_name varchar(45) null comment 'lsports_league 테이블 참조 ',
	fixture_start_date datetime not null comment '경기 시작 시간  _ KST 기준 ',
	fixture_start_date_utc datetime null comment '경기 시작 시간 _ UTC 기준 ',
	fixture_last_update datetime null comment 'LSports 에서 마지막으로 업데이트된 시간 _ UTC 기준',
	fixture_status varchar(2) not null comment '현재 경기 상태
1	Not started yet
2	In progress
3	Finished
4	Cancelled
5	Postponed
6	Interrupted
7	Abandoned
8	Coverage lost
9	About to start	',
	fixture_participants_1_id int null,
	fixture_participants_1_name varchar(100) null,
	fixture_participants_2_id int null,
	fixture_participants_2_name varchar(100) null,
	livescore varchar(21000) null,
	create_dt datetime default current_timestamp() null comment 'KST',
	update_dt datetime default current_timestamp() null on update current_timestamp() comment 'KST',
	delete_dt datetime null comment 'KST',
	live_results_p1 int null,
	live_results_p2 int null,
	m_live_results_p1 int null,
	m_live_results_p2 int null,
	live_time varchar(45) default '' null,
	live_current_period int default 0 null,
	admin_bet_status enum('ON', 'OFF', 'RETRY') default 'ON' null,
	update_data datetime default current_timestamp() null,
	display_status int default 1 null comment '1. 베팅가능=> status 1,9 => 픽스처정보에서 배팅가능은 경기시간에서 -1440분을 뺀 시간부터 -1분까지의 경기
2. 베팅마감 =>status 2,5,6,7,8  => 경기시간에서 59초를 뺀 경기
3. 종료 => status 3,4  =>  결과처리된 경기 또는 4,5,6,7이 들어올시 (경기상세정보에서 적특표기색상으로 해주세요 노란색)
',
	update_type int default 0 null,
	primary key (fixture_id, bet_type)
);

create or replace index idx_dis
	on mydb_deploy.X_lsports_fixtures_innoDB (display_status);

create or replace index idx_fix_id
	on mydb_deploy.X_lsports_fixtures_innoDB (fixture_id);

create or replace index idx_std
	on mydb_deploy.X_lsports_fixtures_innoDB (fixture_start_date);

create or replace index idx_ty_sdt
	on mydb_deploy.X_lsports_fixtures_innoDB (fixture_id, bet_type, fixture_last_update);

create or replace table mydb_deploy.X_lsports_leagues
(
	id int default 0 not null,
	bet_type int not null,
	name varchar(45) null,
	display_name varchar(45) null comment '사용자에게 보여지는 이름 ',
	location_id int null,
	sport_id int null,
	season varchar(45) null,
	lang varchar(4) null,
	create_dt datetime default current_timestamp() null,
	update_dt datetime default current_timestamp() null on update current_timestamp(),
	delete_dt datetime null,
	is_use tinyint default 2 null comment '리그 사용 여부 0 : 미사용 1 : 사용 2 : 대기 ',
	deduction_refund_rate decimal(5,2) default 0.00 null,
	is_margin_refund int default 0 null,
	dividend_rank int unsigned default 1 not null comment '배당금액 등급',
	my_league int default 0 null,
	quarter_time int null,
	image_path varchar(200) default '' null,
	input_refund_rate decimal(5,2) default 0.00 null,
	primary key (id, bet_type)
);

create or replace index ch_idx
	on mydb_deploy.X_lsports_leagues (id, location_id, sport_id, is_use);

create or replace index id
	on mydb_deploy.X_lsports_leagues (id);

create or replace index idx_sp_id
	on mydb_deploy.X_lsports_leagues (sport_id);

create or replace index idx_use
	on mydb_deploy.X_lsports_leagues (is_use);

create or replace table mydb_deploy.X_lsports_locations
(
	idx int auto_increment
		primary key,
	id int null,
	name varchar(45) null,
	name_en varchar(45) null,
	display_name varchar(45) null comment '사용자에게 보여지는 이름 ',
	lang varchar(45) null,
	create_dt datetime default current_timestamp() null,
	update_dt datetime default current_timestamp() null on update current_timestamp(),
	delete_dt datetime null,
	is_use tinyint default 1 null comment '지역 사용 여부 ',
	image_path varchar(200) null comment '지역 이미지 '
);

create or replace index id_index
	on mydb_deploy.X_lsports_locations (id);

create or replace index idx_isuse
	on mydb_deploy.X_lsports_locations (is_use, name);

create or replace index idx_name
	on mydb_deploy.X_lsports_locations (name);

create or replace table mydb_deploy.X_lsports_magin_range
(
	idx int auto_increment
		primary key,
	type int default 0 null,
	min decimal(5,2) default 0.00 not null,
	max decimal(5,2) default 0.00 not null,
	value decimal(5,2) default 0.00 not null
);

create or replace table mydb_deploy.X_lsports_markets
(
	idx int auto_increment
		primary key,
	id int null,
	bet_group tinyint unsigned default 0 null comment '0:기타, 1:스포츠, 2:실시간',
	sport_id int null,
	name varchar(45) null,
	display_name varchar(45) null,
	lang varchar(4) null,
	create_dt datetime default current_timestamp() null,
	update_dt datetime default current_timestamp() null on update current_timestamp(),
	delete_dt datetime null,
	is_delete tinyint default 0 null comment '1: 삭제 ',
	main_book_maker int null,
	sub_book_maker int null,
	menu int null comment '1: 메인 2 : 오버언더 : 3: 핸디캡 4: 그외 5:쿼터 6: 하프 ',
	limit_bet_price decimal(7,2) default 0.00 null,
	max_bet_price decimal(7,2) default 0.00 null,
	not_display_period int default 0 null comment '해당 피어리어드 부터 안보이게 처리 not_display_time 컬럼의 시간값 사용 ',
	not_display_time int default 0 null comment 'not_display_period 의값을 기준으로 해당 퍼리어드에서 몇분지났을때 시간 ',
	not_display_score int default 0 null comment '해당 점수로 안보이게 처리 not_display_score_team_type 컬럼의 데이터에 따라 홈,원정,구분없음으로 처리를 한다.',
	not_display_score_team_type int default 0 null comment '0 :  none 1 :  홈팀 2: 원정 3: 구분없음 ',
	display_order int default 0 null comment '프론트 정렬 순서',
	is_main_menu tinyint default 0 null comment '해당 마켓이 메인메뉴에 노출되는지 여부 0 : 비노출 1: 노출 ',
	main_display_order int default 0 null
);

create or replace index g_d_index
	on mydb_deploy.X_lsports_markets (id, bet_group, is_delete, name, sport_id);

create or replace index id_index
	on mydb_deploy.X_lsports_markets (id);

create or replace index idx_g_d
	on mydb_deploy.X_lsports_markets (bet_group, is_delete, sport_id, main_book_maker);

create or replace table mydb_deploy.X_lsports_participant
(
	idx int auto_increment,
	fp_id int not null comment 'lsports_fixtures. fixture_participants_1(2)_id 와 매칭되는 값 ',
	sports_id int null comment 'lsports_sports.id',
	location_id int null comment 'lsports_locations.id',
	league_id int null comment 'lsports_leagues.id',
	team_name varchar(100) null,
	display_name varchar(45) null comment '사용자들에게 보여지는 값 ',
	is_new tinyint default 1 null,
	primary key (idx, fp_id),
	constraint fp_id_UNIQUE
		unique (fp_id)
);

create or replace index idx_is_new
	on mydb_deploy.X_lsports_participant (is_new);

create or replace table mydb_deploy.X_lsports_refund_rate_market
(
	sports_id int not null,
	league_id int not null,
	market_id int not null,
	bet_type int not null,
	refund_rate decimal(5,2) default 0.00 null,
	deduction_refund_rate decimal(5,2) default 0.00 null,
	is_margin_refund int default 0 null,
	primary key (market_id, sports_id, league_id, bet_type)
);

create or replace table mydb_deploy.X_lsports_sports
(
	idx int auto_increment
		primary key,
	id int null,
	name varchar(45) null,
	display_name varchar(45) null,
	bet_type int null,
	lang varchar(4) null,
	create_dt datetime default current_timestamp() null,
	update_dt datetime default current_timestamp() null on update current_timestamp(),
	delete_dt varchar(45) null,
	is_delete tinyint default 0 null,
	is_use tinyint default 1 null,
	image_path varchar(90) default '' null,
	input_refund_rate decimal(5,2) default 0.00 null,
	deduction_refund_rate decimal(5,2) default 0.00 null,
	is_margin_refund int default 0 null,
	display_order int default 0 null
);

create or replace index id_idx
	on mydb_deploy.X_lsports_sports (id);

create or replace index idx_type
	on mydb_deploy.X_lsports_sports (bet_type);

create or replace index use_type
	on mydb_deploy.X_lsports_sports (is_use, bet_type);

create or replace table mydb_deploy.member
(
	idx int auto_increment
		primary key,
	id varchar(45) not null comment '회원가입시 입력하는 아이디 ',
	password varchar(200) null,
	login_key varchar(200) null,
	nick_name varchar(45) null comment '닉네임 ',
	u_business tinyint default 1 null comment '회원 구분, 1:일반, 2:하위총판,3:총판,4:본사',
	money int default 0 null comment '충전한 현금 ',
	point int default 0 null comment '게임 후 정산된 포인트. 환전할 수도 있고 배팅도 할수 있다.',
	betting_p int default 0 null comment '낙첨포인트',
	`call` varchar(45) null comment '전화 번호',
	is_recommend enum('Y', 'N') default 'N' null comment '추천, Y:가능, N:불가능',
	status tinyint default 11 null comment '회원상태 ( 1:정상, 2:정지, 3:탈퇴, 11:승인 대기회원 )',
	level int default 1 null,
	auto_level enum('Y', 'N') default 'Y' null comment '자동렙업, Y:on, N:off',
	last_login datetime null comment '최종 로그인',
	last_page varchar(45) null comment '마지막 접속 위치 ',
	recommend_code varchar(45) null comment '추천인 코드',
	recommend_member int default 0 null comment '사용자 입력 추천인 회원 idx ',
	recommend_code_dt datetime null,
	account_number varchar(45) null comment '계좌 번호 ',
	account_name varchar(45) null comment '계좌 소유주 이름 ',
	account_bank varchar(45) null comment '계좌 은행 ',
	exchange_password varchar(200) null comment '환전 비밀 번호 ',
	is_monitor enum('Y', 'N') default 'N' null comment '일반 모니터링 Y:on, N:off',
	is_monitor_charge enum('Y', 'N') default 'N' null comment '충전 모니터링 Y:on, N:off',
	is_monitor_security enum('Y', 'N') default 'N' null comment '보안 모니터링 Y:on, N:off',
	is_monitor_bet enum('Y', 'N') default 'N' null comment '중복베팅 모니터링 Y:on, N:off',
	dis_id varchar(45) null comment '소속 총판 ID',
	dis_line_id varchar(45) null comment '소속 총판라인 ID',
	reg_time timestamp default current_timestamp() null comment '등록일',
	mod_time timestamp null comment '수정일',
	leave_time timestamp null comment '탈퇴일',
	admin_memo varchar(45) null comment '관리자 메모 ',
	regenerate varchar(45) default '' not null,
	session_key varchar(100) null,
	random_code varchar(45) null,
	reg_first_charge int default 0 null,
	charge_first_per int default 0 null,
	is_exchange int default 0 null,
	is_sound enum('Y', 'N') default 'Y' null,
	access_token varchar(512) default '' null,
	transaction_key varchar(45) default '' null,
	is_coin_guid enum('Y', 'N') default 'N' null,
	coin_password varchar(200) default '' null
)
comment '회원 테이블';

create or replace index dis_id
	on mydb_deploy.member (dis_id);

create or replace index id
	on mydb_deploy.member (id);

create or replace index idx_u_business
	on mydb_deploy.member (u_business);

create or replace index lv_idx
	on mydb_deploy.member (level);

create or replace index rc_idx
	on mydb_deploy.member (recommend_member);

create or replace table mydb_deploy.member_bet
(
	idx int auto_increment
		primary key,
	u_key varchar(64) null comment 't_log_cash 연동 키 ',
	member_idx int null comment '유저 아이디 -MemberModel',
	bet_type int default 0 null comment '1 : 프리매치 2: 실시간 3 : 파워볼,4파워사다리 5: 키노사다리 6 : 가상축구 ',
	bet_status int default 1 null comment '1: 게임 결과 전\\\\n2: 적중 - 정산 전 \\\\n3: 적중 - 정산 완료\\\\n4: 적중 실패 \\\\n5: 취소 , \\\\n 6:적특',
	game_type int default 0 null,
	bonus_price double default 1 null comment '3폴더, 5폴더 이상 보너스 처리 위함. 정산시 입력 됨.',
	total_bet_money int null comment '총 배팅 금액',
	create_dt datetime default current_timestamp() not null,
	update_dt datetime default current_timestamp() not null on update current_timestamp(),
	delete_dt datetime null,
	calculate_dt datetime default current_timestamp() not null comment '정산처리 시간',
	folder_type enum('S', 'D') null comment 'S 싱글 D : 다폴더',
	round int default 0 null,
	take_money int default 0 null,
	is_open tinyint default 0 null comment '0-운영자 미확인, 1-운영자 확인',
	is_hide tinyint default 0 null comment '0-유저 보이기, 1-유저 숨기기',
	take_point int default 0 null,
	recom_take_point int default 0 null,
	cancel_type tinyint default 0 null comment '취소타입(0-유저, 1-관리자)',
	passivity_hit_flag tinyint default 0 null comment '0 : 자동 적특 1: 수동적특 '
)
comment '배팅 내역 ';

create or replace index create_dt
	on mydb_deploy.member_bet (create_dt);

create or replace index idx_bt_type
	on mydb_deploy.member_bet (bet_type);

create or replace index index_bt_stat
	on mydb_deploy.member_bet (bet_status);

create or replace index index_mb_id
	on mydb_deploy.member_bet (member_idx);

create or replace table mydb_deploy.X_member_bet_detail
(
	idx int auto_increment
		primary key,
	bet_idx int null comment '배팅 아이디 -MemberBetModel',
	ls_bet_id bigint null comment 'LS 배팅 아이디 -LSportsBetModel',
	ls_fixture_id int null,
	ls_markets_id int null,
	ls_markets_name varchar(45) null,
	ls_markets_base_line varchar(45) null,
	bet_type int default 0 null,
	bet_price double null comment '배팅 당시 !! 사용자가 배팅 한 !! 마켓에 대한 배당률',
	bet_status int default 1 null comment '1: 게임 결과 전\\\\\\\\\\\\\\\\n2: 적중 - 정산 전\\\\\\\\\\\\\\\\n3: 적중 - 정산 완료\\\\\\\\\\\\\\\\n4: 적중 실패  \\\\\\\\n5: 취소, \\\\\\\\n 6:적특',
	bet_name varchar(45) default '' null,
	create_dt datetime default current_timestamp() not null,
	update_dt datetime default current_timestamp() not null on update current_timestamp(),
	delete_dt datetime null,
	fixture_start_date datetime null,
	fixture_sport_id int default 0 null,
	fixture_location_id int default 0 null,
	fixture_league_id int default 0 null,
	fixture_participants_1_id int default 0 null,
	fixture_participants_2_id int default 0 null,
	result_score mediumtext default '' null,
	passivity_hit_flag tinyint default 0 null comment '0 : 자동적특  1 : 수동적특'
)
comment '배팅 내역 상세';

create or replace index bet_id
	on mydb_deploy.X_member_bet_detail (ls_bet_id);

create or replace index bs_index
	on mydb_deploy.X_member_bet_detail (bet_status);

create or replace index create_dt
	on mydb_deploy.X_member_bet_detail (fixture_start_date);

create or replace index index_bet_id
	on mydb_deploy.X_member_bet_detail (bet_idx);

create or replace index index_fix_id
	on mydb_deploy.X_member_bet_detail (ls_fixture_id, bet_type, bet_status);

create or replace index ls_markets_id
	on mydb_deploy.X_member_bet_detail (ls_markets_id);

create or replace table mydb_deploy.X_member_betting_mini_and_hash_history
(
	idx int auto_increment
		primary key,
	member_idx int null,
	data_type varchar(10) null comment '미니게임 / 해쉬게임 ',
	game_type varchar(45) null comment '하이로우, 룰렛, 바카라 … ',
	channel varchar(45) null,
	round int null comment '회차. ',
	betting_money int null,
	hit_money int null,
	result varchar(45) null,
	betting_datetime varchar(45) null
);

create or replace table mydb_deploy.X_member_betting_prematch_and_realtime_history
(
	idx int auto_increment
		primary key,
	member_idx int null,
	game_type varchar(10) null,
	game_cnt int null,
	odds double null comment '배당률',
	betting_money int null,
	expwin_money varchar(45) null comment '예상 당첨 금액 (expected winnings) ',
	betting_datetime datetime null,
	result varchar(45) null,
	cancel varchar(45) null
);

create or replace table mydb_deploy.member_ip_block_history
(
	idx int auto_increment
		primary key,
	admin_id varchar(50) null,
	member_idx int null,
	login_history_idx int null,
	ip varchar(45) null,
	country varchar(45) null,
	memo varchar(45) null,
	create_dt datetime default current_timestamp() null,
	constraint UQ_IP_BLOCK_U01
		unique (ip)
);

create or replace index idx_create
	on mydb_deploy.member_ip_block_history (create_dt);

create or replace table mydb_deploy.member_login_history
(
	idx int auto_increment
		primary key,
	member_idx int null,
	ip varchar(45) null,
	country varchar(45) null,
	block varchar(45) null,
	login_domain varchar(100) null comment '접속 도메인',
	agent text null comment 'user agent 정보',
	agent_hash varchar(50) null,
	agent_device varchar(50) null comment 'user agent 정보, 디바이스',
	agent_browser varchar(50) null comment 'user agent 정보, 브라우저',
	login_yn enum('Y', 'N') null comment 'login Y: 성공, N:실패',
	login_datetime datetime default current_timestamp() null
)
comment '로그인 내역 ';

create or replace index idx_mb_idx
	on mydb_deploy.member_login_history (member_idx, ip);

create or replace table mydb_deploy.member_money_charge_history
(
	idx int auto_increment
		primary key,
	u_key varchar(64) null comment 't_log_cash u_key 와 연결 ',
	member_idx int null comment '충전 신청자 멤버 idx ',
	admin_idx int null comment '관리자 idx ',
	deposit_name varchar(45) null comment '입금자 명 ',
	bank_id int default 0 null,
	bank_name varchar(45) default '' null,
	account_number varchar(45) default '' null,
	account_name varchar(45) default '' null,
	money int null comment '충전 금액 ',
	result_money int default 0 null,
	bonus_money int null,
	bonus_point int default 0 null,
	set_type varchar(50) default '' null,
	status int null comment '1: 입금 전 (신청) 2: 입금 확인 (대기) 3: 충전 완료 (완료) 4: 취소 10: 배팅적중 11:관리자 취소  \\n999: 오류',
	comment varchar(100) null comment 'Status comment ',
	create_dt datetime default current_timestamp() null,
	update_dt datetime null comment '관리자 처리 일자',
	delete_dt datetime null,
	referenceId varchar(45) default '' null,
	sms_status varchar(45) default '' null,
	is_sound enum('Y', 'N') default 'Y' null
)
comment '충전 / 환전 내역 ';

create or replace index idx_create_dt
	on mydb_deploy.member_money_charge_history (create_dt);

create or replace index idx_mb_idx
	on mydb_deploy.member_money_charge_history (member_idx);

create or replace index idx_status
	on mydb_deploy.member_money_charge_history (status);

create or replace index status_member_idx
	on mydb_deploy.member_money_charge_history (status, member_idx);

create or replace table mydb_deploy.member_money_charge_sms
(
	idx int auto_increment
		primary key,
	deposit_name varchar(45) null comment '입금자 명 ',
	bank_id int default 0 null comment '은행번호',
	bank_name varchar(45) default '0' null comment '은행명',
	money int null comment '충전 금액 ',
	status int null comment '1: 입금 전 (신청) 2: 시간초과(완료) 3: 자동충전 완료 (완료) 4: 운영자 완료 \\\\\\\\n999: 오류',
	create_dt datetime default current_timestamp() null,
	update_dt datetime null comment '처리 일자',
	ori text default '' null comment '원문'
)
comment '입금sms 내역';

create or replace index idx_st
	on mydb_deploy.member_money_charge_sms (status);

create or replace index st_bk_idx
	on mydb_deploy.member_money_charge_sms (deposit_name, bank_id, money, create_dt);

create or replace table mydb_deploy.member_money_exchange_history
(
	idx int auto_increment
		primary key,
	u_key varchar(64) null comment 't_log_cash u_key 와 연결 ',
	member_idx int null comment '환전 신청자 멤버 idx ',
	admin_idx int null comment '관리자 idx ',
	money int null comment '환전 금액 ',
	result_money int default 0 null,
	comment varchar(100) null comment 'Status comment ',
	create_dt datetime default current_timestamp() null,
	update_dt datetime default current_timestamp() null on update current_timestamp(),
	delete_dt datetime null,
	set_type varchar(50) default '' null,
	is_sound enum('Y', 'N') default 'Y' null,
	status int null comment '1: 입금 전 (신청) 2: 입금 확인 (대기) 3: 충전 완료 (완료) 4: 취소 10: 배팅적중 11:관리자 취소  \\n999: 오류'
)
comment '환전 내역 ';

create or replace index idx_create_dt
	on mydb_deploy.member_money_exchange_history (create_dt);

create or replace index idx_s_u_m
	on mydb_deploy.member_money_exchange_history (member_idx);

create or replace index status_member_idx
	on mydb_deploy.member_money_exchange_history (status, member_idx);

create or replace table mydb_deploy.member_money_history
(
	idx int auto_increment comment '배팅 머니 사용 내역 '
		primary key,
	member_idx int null,
	money int null,
	type int null comment '금액 타입
- 사용(배팅): 1
- 충전: 2
- 환전: 3
-',
	type_idx int null comment '사용처 idx
- 1: member_bet.idx
- 2: member_money_charge.idx
- 3: member_money_exchange.idx',
	create_dt datetime default current_timestamp() null,
	update_dt datetime default current_timestamp() null on update current_timestamp(),
	delete_dt datetime null
);

create or replace table mydb_deploy.member_point_history
(
	idx int auto_increment
		primary key,
	member_idx int null,
	use_point int null comment '변동 금액 ',
	bef_point int null comment '변동 금액 ',
	use_type varchar(45) null comment '사용 타입 '
)
comment '회원 보유 머니 ';

create or replace table mydb_deploy.member_summary
(
	member_idx int default 0 not null comment '유저번호'
		primary key,
	total_deposit_money int null comment '총입금액',
	total_withdraw_money int null comment '총출금액',
	total_deposit_count int null comment '총입금횟수',
	total_withdraw_count int null comment '총출금횟수',
	max_deposit_money int null comment '최대 입금액',
	max_withdraw_money int null comment '최대 출금액',
	total_betting_money int null comment '총 배팅금액',
	total_betting_count int null comment '총 배팅횟수',
	total_betting_win_money int null comment '총 당첨금액'
)
comment '유저 종합내역';

create or replace table mydb_deploy.member_update_history
(
	idx int auto_increment
		primary key,
	member_idx int null,
	update_type varchar(45) null comment '변경 항목 ',
	before_data text null,
	after_data text null,
	create_dt timestamp default current_timestamp() null
)
comment '로그인 내역 ';

create or replace table mydb_deploy.menu_board
(
	idx int auto_increment
		primary key,
	member_idx int null comment '글쓴이 (회원) ',
	a_id varchar(45) null comment '담당자 (관리자) ',
	nick_name varchar(45) default '' null,
	title varchar(100) null,
	contents text null,
	create_dt datetime default current_timestamp() null,
	display tinyint default 0 not null comment '노출여부'
)
comment '메뉴 상단 ‘게시판’';

create or replace index member_idx_create_dt
	on mydb_deploy.menu_board (member_idx, create_dt);

create or replace table mydb_deploy.menu_board_comment
(
	idx int(10) auto_increment comment '댓글 idx'
		primary key,
	board_idx int not null comment '글번호 idx',
	member_idx int not null comment '작성자 idx',
	nick_name varchar(45) not null comment '닉네임',
	comment text not null comment '댓글',
	display tinyint(1) default 1 not null comment '노출 여부 (0: 미노출, 1: 노출)',
	create_dt datetime default current_timestamp() null comment '작성일'
)
comment '게시판 댓글';

create or replace index IDX_BOARD_IDX
	on mydb_deploy.menu_board_comment (board_idx);

create or replace table mydb_deploy.menu_qna
(
	idx int auto_increment
		primary key,
	member_idx int null comment '글쓴이 (회원) ',
	a_id varchar(45) null comment '담당자 (관리자) ',
	title varchar(100) null,
	contents text null,
	is_answer enum('Y', 'N') default 'N' null,
	is_view enum('Y', 'N') default 'Y' null,
	is_status enum('Y', 'D') default 'Y' null,
	is_sound enum('Y', 'N') default 'Y' null comment '운영툴에서 소리를 낼지 말지 판단',
	answer text null,
	create_dt datetime default current_timestamp() null
)
comment '메뉴 상단 ‘고객센터’';

create or replace index idx_an
	on mydb_deploy.menu_qna (is_answer);

create or replace index idx_mb_idx
	on mydb_deploy.menu_qna (is_view);

create or replace index idx_sd
	on mydb_deploy.menu_qna (is_sound);

create or replace index member_idx_create_dt
	on mydb_deploy.menu_qna (create_dt);

create or replace table mydb_deploy.X_mini_game
(
	game varchar(16) default '' not null comment '게임',
	id int default 0 not null comment '회차',
	cnt int default 0 null,
	bet_type int null comment '1 : 프리매치 2: 실시간 3 : 파워볼,4파워사다리 5: 키노사다리 6 : 가상축구 ',
	admin_bet_status enum('ON', 'OFF', 'RETRY') default 'ON' null,
	start_dt datetime default current_timestamp() null comment 'KST ',
	end_dt datetime default current_timestamp() null comment 'KST ',
	result mediumtext default '' null,
	result_score mediumtext default '' null,
	league varchar(45) default '' null,
	primary key (game, id)
);

create or replace index bet_type
	on mydb_deploy.X_mini_game (bet_type);

create or replace index idx_game
	on mydb_deploy.X_mini_game (game);

create or replace index idx_id
	on mydb_deploy.X_mini_game (id);

create or replace index start_dt
	on mydb_deploy.X_mini_game (start_dt, end_dt);

create or replace table mydb_deploy.X_mini_game_bet
(
	game varchar(16) default '' not null comment '게임',
	markets_id int not null comment '마켓 아이디',
	markets_name varchar(45) default '0' null comment '마켓명',
	bet_price double null comment '베당률',
	primary key (game, markets_id)
)
comment '배팅';

create or replace index idx_game
	on mydb_deploy.X_mini_game_bet (game);

create or replace index markets_id
	on mydb_deploy.X_mini_game_bet (markets_id);

create or replace table mydb_deploy.X_mini_game_bet_config
(
	bet_type int default 0 not null comment '1 : 프리매치 2: 실시간 3 : 파워볼,4파워사다리 5: 키노사다리 6 : 가상축구 ',
	game varchar(16) default '' not null comment '게임',
	level int default 0 not null comment '레벨',
	min int default 0 null comment '최소',
	max int default 0 null comment '최대',
	`limit` int default 0 null comment '상한',
	reward decimal(5,2) default 0.00 null comment '리워드%',
	primary key (bet_type, level)
)
comment '배팅 설정';

create or replace table mydb_deploy.X_mini_game_member_bet
(
	idx int auto_increment
		primary key,
	u_key varchar(64) null comment 't_log_cash 연동 키 ',
	member_idx int default 0 null comment '유저 아이디 -MemberModel',
	bet_type int default 0 null comment '1 : 프리매치 2: 실시간 3 : 파워볼,4파워사다리 5: 키노사다리 6 : 가상축구 ',
	bet_status int default 1 null comment '1: 게임 결과 전\\\\n2: 적중 - 정산 전 \\\\n3: 적중 - 정산 완료\\\\n4: 적중 실패 \\\\n5: 취소 , \\\\n 6:적특',
	total_bet_money int default 0 null comment '총 배팅 금액',
	bet_price double default 0 null comment '배당률',
	create_dt datetime default current_timestamp() not null,
	update_dt datetime default current_timestamp() not null on update current_timestamp(),
	calculate_dt datetime default current_timestamp() not null comment '정산처리 시간',
	ls_fixture_id int default 0 null comment '경기 회차번호',
	ls_markets_id int default 0 null,
	ls_markets_name varchar(45) null,
	round int default 0 null comment '미니게임 회차번호',
	take_money int default 0 null,
	take_point int default 0 null,
	is_open tinyint default 0 null comment '0-운영자 미확인, 1-운영자 확인',
	is_hide tinyint default 0 null comment '0-유저 보이기, 1-유저 숨기기'
)
comment '미니게임 배팅내역 ';

create or replace index idx_ct
	on mydb_deploy.X_mini_game_member_bet (ls_markets_id, create_dt);

create or replace index idx_stats
	on mydb_deploy.X_mini_game_member_bet (bet_status, total_bet_money, take_money);

create or replace index index_bet_type
	on mydb_deploy.X_mini_game_member_bet (bet_type);

create or replace index index_bt_stat
	on mydb_deploy.X_mini_game_member_bet (bet_status);

create or replace index index_is_open
	on mydb_deploy.X_mini_game_member_bet (is_open);

create or replace index index_mb_id
	on mydb_deploy.X_mini_game_member_bet (member_idx);

create or replace table mydb_deploy.notices
(
	idx int auto_increment
		primary key,
	name varchar(45) default '' null,
	thumbnail varchar(1024) default '' null,
	detail varchar(1024) default '' null,
	status tinyint default 1 null comment '0-미사용, 1-사용',
	del_flag tinyint default 0 null comment '0-존재, 1-삭제됨',
	create_dt datetime default current_timestamp() null,
	update_dt datetime default current_timestamp() null on update current_timestamp(),
	delete_dt datetime default current_timestamp() null
)
comment '공지테이블';

create or replace table mydb_deploy.shop_calculate_result
(
	member_idx int default 0 not null comment '유저번호(매장)',
	create_dt datetime default current_timestamp() not null,
	calculate_point decimal(7,2) default 0.00 null comment '정산금',
	ch_val decimal(7,2) default 0.00 null comment '입금',
	ex_val decimal(7,2) default 0.00 null comment '출금',
	pre_bet_sum_s decimal(7,2) default 0.00 null comment '프리싱글 정산금',
	pre_bet_sum_d decimal(7,2) default 0.00 null comment '프리멀티 정산금',
	real_bet_sum_s decimal(7,2) default 0.00 null comment '실시간싱글 정산금',
	real_bet_sum_d decimal(7,2) default 0.00 null comment '실시간멀티 정산금',
	mini_bet_sum decimal(7,2) default 0.00 null comment '미니게임 정산금',
	bet_pre_s_fee decimal(7,2) default 0.00 null comment '베팅롤링 프리매치싱글 수수료',
	bet_pre_d_fee decimal(7,2) default 0.00 null comment '베팅롤링 프리매치다폴더 수수료',
	bet_real_s_fee decimal(7,2) default 0.00 null comment '베팅롤링 실시간싱글 수수료',
	bet_real_d_fee decimal(7,2) default 0.00 null comment '베팅롤링 실시간다폴더 수수료',
	bet_mini_fee decimal(7,2) default 0.00 null comment '베팅롤링 미니게임 수수료',
	pre_s_fee decimal(7,2) default 0.00 null comment '죽장 수수료',
	primary key (member_idx, create_dt)
)
comment '총판 정산';

create or replace table mydb_deploy.shop_config
(
	member_idx int default 0 not null comment '유저번호(매장)'
		primary key,
	bet_pre_s_fee decimal(7,2) default 0.00 null comment '베팅롤링 프리매치싱글',
	bet_pre_d_fee decimal(7,2) default 0.00 null comment '베팅롤링 프리매치다폴더',
	bet_real_s_fee decimal(7,2) default 0.00 null comment '베팅롤링 실시간싱글',
	bet_real_d_fee decimal(7,2) default 0.00 null comment '베팅롤링 실시간다폴더',
	bet_mini_fee decimal(7,2) default 0.00 null comment '베팅롤링 미니게임',
	pre_s_fee decimal(7,2) default 0.00 null comment '죽장 프리매치싱글',
	pre_d_fee decimal(7,2) default 0.00 null comment '죽장 프리매치다폴더',
	real_s_fee decimal(7,2) default 0.00 null comment '죽장 실시간싱글',
	real_d_fee decimal(7,2) default 0.00 null comment '죽장 실시간다폴더',
	mini_fee decimal(7,2) default 0.00 null comment '죽장 미니게임'
)
comment '매장별 수수료 설정';

create or replace table mydb_deploy.shop_config_request
(
	member_idx int default 0 not null comment '유저번호(매장)'
		primary key,
	bet_pre_s_fee int null comment '베팅롤링 프리매치싱글',
	bet_pre_d_fee int null comment '베팅롤링 프리매치다폴더',
	bet_real_s_fee int null comment '베팅롤링 실시간싱글',
	bet_real_d_fee int null comment '베팅롤링 실시간다폴더',
	bet_mini_fee int null comment '베팅롤링 미니게임',
	pre_s_fee int null comment '죽장 프리매치싱글',
	pre_d_fee int null comment '죽장 프리매치다폴더',
	real_s_fee int null comment '죽장 실시간싱글',
	real_d_fee int null comment '죽장 실시간다폴더',
	mini_fee int null comment '죽장 미니게임',
	is_process int default 0 null comment '0-처리됨, 1-처리필요'
)
comment '매장별 수수료 변경요청';

create or replace table mydb_deploy.sms_auth
(
	idx int auto_increment
		primary key,
	phone_number varchar(45) null,
	auth_number varchar(45) null,
	create_dt datetime default current_timestamp() null,
	status int default 1 null comment '1-요청, 2-인증완료'
);

create or replace table mydb_deploy.X_sports_rule
(
	id int default 0 not null comment '종목번호',
	betting_type varchar(32) not null comment '베팅타입',
	betting_name varchar(32) null comment '종목명',
	application_time varchar(16) not null comment '적용시간',
	contents varchar(8) null comment '설명',
	primary key (id, betting_type)
);

create or replace table mydb_deploy.X_sports_rule_2
(
	id int default 0 not null comment '종목번호',
	type varchar(16) not null comment '타입 및 경기시간',
	contents varchar(8) null comment '설명',
	primary key (id, type)
);

create or replace table mydb_deploy.X_t_domain_code
(
	idx int unsigned auto_increment
		primary key,
	domain varchar(100) null,
	domain_code varchar(100) null,
	is_use enum('Y', 'N') default 'Y' null,
	reg_time timestamp default current_timestamp() not null,
	constraint UQ_DOMAIN_01
		unique (domain_code)
);

create or replace table mydb_deploy.t_game_config
(
	idx int unsigned auto_increment
		primary key,
	u_level tinyint unsigned default 0 not null,
	set_type varchar(50) not null,
	set_type_val varchar(200) not null,
	title varchar(200) not null,
	reg_time timestamp default current_timestamp() not null,
	constraint UQ_GAME_CONFIG_01
		unique (u_level, set_type)
);

create or replace index idx_type
	on mydb_deploy.t_game_config (set_type);

create or replace table mydb_deploy.t_ip_country
(
	idx int unsigned auto_increment
		primary key,
	country_code varchar(10) null,
	country varchar(50) null,
	ip_start int unsigned not null,
	ip_end int unsigned not null
);

create or replace table mydb_deploy.t_log_cash
(
	idx int unsigned auto_increment
		primary key,
	u_key varchar(64) null,
	member_idx int not null,
	ac_code smallint default 0 null comment '    /*1:충전,2:환전,3:베팅,4:베팅취소,5:포인트전환(추가),6:포인트차감,10:포인트충전,7:베팅결과처리,8:이벤트충전,9:이벤트차감,101:충전요청,102:환전요청,103:계좌조회,\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n             * 111:충전요청취소,112:환전요청취소,113:충전취소,114:환전취소,121:관리자충전,122:관리자회수,123:관리자 포인트 충전, 124:관리자 포인트 회수,125 : 관리자 환전 회수,998:데이터복구,999:기타 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n     \\\\\\\\\\\\\\\\n201 : 정산 취소,202 : 정산 포인트 취소,203 : 정산 추천인 포인트 취소,204 : 충전 대기 ,205 : 환전요청 대기, 301 : 총판정산,302 : 코인충전요청, 303:코인충전완료, 304:미입금유저레벨 변경       */',
	ac_idx int null,
	r_money int default 0 not null,
	be_r_money int default 0 not null,
	af_r_money int default 0 not null,
	point int default 0 not null,
	be_point int default 0 not null,
	af_point int default 0 not null,
	m_kind enum('R', 'P', 'M') default 'R' not null,
	title_kind varchar(30) null,
	coment text null,
	u_ip varchar(30) null,
	a_id varchar(30) null,
	reg_time timestamp default current_timestamp() not null
);

create or replace index ac_code
	on mydb_deploy.t_log_cash (ac_code);

create or replace index member_idx
	on mydb_deploy.t_log_cash (member_idx);

create or replace index reg_time
	on mydb_deploy.t_log_cash (reg_time);

create or replace table mydb_deploy.t_member_memo
(
	idx int unsigned auto_increment
		primary key,
	member_idx int unsigned default 0 not null,
	m_type tinyint default 1 not null,
	content varchar(300) null,
	a_id varchar(50) null,
	reg_time timestamp default current_timestamp() not null
);

create or replace table mydb_deploy.t_message
(
	idx int unsigned auto_increment
		primary key,
	msg_idx int unsigned not null,
	member_idx int unsigned not null,
	read_yn enum('Y', 'N') default 'N' not null,
	u_ip varchar(30) null,
	reg_time timestamp default current_timestamp() not null comment '등록일',
	read_time datetime null,
	is_delete int(10) default 0 null
);

create or replace index idx_mb_idx
	on mydb_deploy.t_message (member_idx);

create or replace table mydb_deploy.t_message_list
(
	idx int unsigned auto_increment
		primary key,
	idx_key char(25) not null,
	title varchar(200) not null,
	content longtext not null,
	a_id varchar(50) null,
	a_view_nick varchar(100) null,
	w_type enum('A', 'H') default 'H' not null,
	reg_time timestamp default current_timestamp() not null comment '등록일',
	constraint UQ_MESSAGE_LIST_U01
		unique (idx_key)
);

create or replace table mydb_deploy.t_message_set
(
	idx int unsigned auto_increment
		primary key,
	a_id varchar(50) not null,
	title_view varchar(200) not null,
	title varchar(200) not null,
	content text not null,
	use_kind enum('Y', 'N') default 'N' not null,
	send_cnt int unsigned default 0 not null,
	reg_time timestamp default current_timestamp() not null
);

create or replace table mydb_deploy.template
(
	idx int auto_increment
		primary key,
	type int not null comment '0-쪽지, 1-답변',
	division varchar(128) null comment '분류',
	title text null comment '내용',
	content longtext null,
	update_dt datetime default current_timestamp() null
);

create or replace table mydb_deploy.virtual_goods_list
(
	p_seq int default 0 not null comment '상품등록 코드'
		primary key,
	p_name varchar(32) null comment '종목명',
	p_price int unsigned default 0 not null comment '마감시간',
	p_sell_state varchar(32) null comment '상품 판매 상태 (SELL:판매중, SOLDOUT:판매완료)'
);

create or replace index idx_p_price
	on mydb_deploy.virtual_goods_list (p_price);

