This commit is contained in:
shoopea 2019-06-25 17:54:46 +08:00
parent b200e38a58
commit 7803264992

46
sql.go
View File

@ -49,7 +49,7 @@ func initDB() {
,name VARCHAR(80) NOT NULL
,PRIMARY KEY (id)
,UNIQUE KEY (intl_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table code_obj_type")
log.Println("initDB : code_obj_type created ...")
@ -61,7 +61,7 @@ func initDB() {
,PRIMARY KEY (id)
,UNIQUE KEY (intl_id)
,FOREIGN KEY (obj_type_id) REFERENCES code_obj_type(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table code_obj_sub_type")
log.Println("initDB : code_obj_sub_type created ...")
@ -73,7 +73,7 @@ func initDB() {
,PRIMARY KEY (id)
,FOREIGN KEY (obj_type_id) REFERENCES code_obj_type(id) ON DELETE CASCADE
,FOREIGN KEY (obj_sub_type_id) REFERENCES code_obj_sub_type(id) ON DELETE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj")
log.Println("initDB : obj created ...")
@ -82,7 +82,7 @@ func initDB() {
,logo VARCHAR(32) NOT NULL
,name VARCHAR(80) NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_castle")
log.Println("initDB : obj_guild created ...")
@ -93,7 +93,7 @@ func initDB() {
,chat_id BIGINT
,deposit_chat_id BIGINT
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_guild")
log.Println("initDB : obj_guild created ...")
@ -101,7 +101,7 @@ func initDB() {
obj_id BIGINT UNSIGNED NOT NULL
,name VARCHAR(80) NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_user")
log.Println("initDB : obj_user created ...")
@ -110,7 +110,7 @@ func initDB() {
,start_time DATETIME NOT NULL
,end_time DATETIME NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_war")
log.Println("initDB : obj_war created ...")
@ -124,7 +124,7 @@ func initDB() {
,text VARCHAR(4096) NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY (msg_id, chat_id, sender_user_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg")
log.Println("initDB : obj_msg created ...")
@ -135,7 +135,7 @@ func initDB() {
,castle_id BIGINT UNSIGNED NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,FOREIGN KEY (castle_id) REFERENCES obj_castle(obj_id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_report")
log.Println("initDB : obj_msg_report created ...")
@ -144,7 +144,7 @@ func initDB() {
,war_id BIGINT UNSIGNED NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,FOREIGN KEY (war_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_report")
log.Println("initDB : obj_msg_report created ...")
@ -162,7 +162,7 @@ func initDB() {
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,FOREIGN KEY (war_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY (user_id, war_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_war_report")
log.Println("initDB : obj_war_report created ...")
@ -189,7 +189,7 @@ func initDB() {
,FOREIGN KEY (seller_castle_id) REFERENCES obj_castle(obj_id) ON DELETE CASCADE
,FOREIGN KEY (buyer_castle_id) REFERENCES obj_castle(obj_id) ON DELETE CASCADE
,KEY (lot_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_auction_announce")
log.Println("initDB : obj_msg_auction_announce created ...")
@ -198,7 +198,7 @@ func initDB() {
,date DATETIME NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY (date)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_mini_war")
log.Println("initDB : obj_msg_mini_war created ...")
@ -213,7 +213,7 @@ func initDB() {
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,FOREIGN KEY (castle_id) REFERENCES obj_castle(obj_id) ON DELETE CASCADE
,UNIQUE KEY (obj_id, castle_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_mini_war_castle")
log.Println("initDB : obj_msg_mini_war_castle created ...")
@ -236,7 +236,7 @@ func initDB() {
,FOREIGN KEY (loss_guild_id) REFERENCES obj_guild(obj_id) ON DELETE CASCADE
,FOREIGN KEY (win_user_id) REFERENCES obj_user(obj_id) ON DELETE CASCADE
,FOREIGN KEY (loss_user_id) REFERENCES obj_user(obj_id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_duel_fight")
log.Println("initDB : obj_msg_duel_fight created ...")
@ -245,7 +245,7 @@ func initDB() {
,lot_id BIGINT UNSIGNED NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,KEY (lot_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_auction_upd_req")
log.Println("initDB : obj_msg_auction_upd_req created ...")
@ -255,7 +255,7 @@ func initDB() {
,buyer VARCHAR(32)
,item VARCHAR(80)
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_auction_upd_ack")
log.Println("initDB : obj_msg_auction_upd_ack created ...")
@ -266,7 +266,7 @@ func initDB() {
,rule VARCHAR(4096) NOT NULL
,msg_type_id SMALLINT UNSIGNED NOT NULL
,UNIQUE KEY (id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table msg_rules")
log.Println("initDB : msg_rules created ...")
@ -276,7 +276,7 @@ func initDB() {
,weight SMALLINT NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY (intl_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_item")
log.Println("initDB : obj_item created ...")
@ -291,7 +291,7 @@ func initDB() {
,FOREIGN KEY (user_id) REFERENCES obj_user(obj_id) ON DELETE CASCADE
,FOREIGN KEY (item_id) REFERENCES obj_item(obj_id) ON DELETE CASCADE
,UNIQUE KEY (user_id, date)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_tribute")
log.Println("initDB : obj_tribute created ...")
@ -305,7 +305,7 @@ func initDB() {
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,FOREIGN KEY (user_id) REFERENCES obj_user(obj_id) ON DELETE CASCADE
,UNIQUE KEY (user_id, date)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_xp")
log.Println("initDB : obj_xp created ...")
@ -327,7 +327,7 @@ func initDB() {
,KEY (is_done)
,KEY (in_work)
,KEY (user_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_job")
log.Println("initDB : obj_job created ...")
@ -337,7 +337,7 @@ func initDB() {
,priority INT UNSIGNED NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY(name)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;`)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_name")
log.Println("initDB : obj_name created ...")