This commit is contained in:
shoopea 2019-06-25 17:53:19 +08:00
parent 5bf8707ba8
commit b200e38a58

46
sql.go
View File

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