This commit is contained in:
shoopea 2019-05-06 21:48:43 +08:00
parent 226f56126d
commit d745613664

14
sql.go
View File

@ -46,7 +46,7 @@ func initDB() {
,intl_id VARCHAR(32) NOT NULL ,intl_id VARCHAR(32) NOT NULL
,name VARCHAR(80) NOT NULL ,name VARCHAR(80) NOT NULL
,PRIMARY KEY (id) ,PRIMARY KEY (id)
) ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_unicode_ci;`) ) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table code_obj_type") failOnError(err, "initDB : create table code_obj_type")
_, err = db.Exec(`CREATE TABLE code_obj_sub_type ( _, err = db.Exec(`CREATE TABLE code_obj_sub_type (
@ -56,7 +56,7 @@ func initDB() {
,obj_type_id SMALLINT UNSIGNED NOT NULL ,obj_type_id SMALLINT UNSIGNED NOT NULL
,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
) ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_unicode_ci;`) ) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table code_obj_sub_type") failOnError(err, "initDB : create table code_obj_sub_type")
_, err = db.Exec(`CREATE TABLE obj ( _, err = db.Exec(`CREATE TABLE obj (
@ -64,7 +64,7 @@ func initDB() {
,obj_type_id SMALLINT UNSIGNED NOT NULL ,obj_type_id SMALLINT UNSIGNED NOT NULL
,obj_sub_type_id SMALLINT UNSIGNED NOT NULL ,obj_sub_type_id SMALLINT UNSIGNED NOT NULL
,PRIMARY KEY (id) ,PRIMARY KEY (id)
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARSET=utf8 COLLATE utf8_unicode_ci;`) ) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table obj") failOnError(err, "initDB : create table obj")
_, err = db.Exec(`CREATE TABLE obj_user ( _, err = db.Exec(`CREATE TABLE obj_user (
@ -77,7 +77,7 @@ func initDB() {
,busy_until TIMESTAMP ,busy_until TIMESTAMP
,role ENUM('commander', 'bartender', 'squire', 'none') ,role ENUM('commander', 'bartender', 'squire', 'none')
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE ,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_unicode_ci;`) ) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table obj_user") failOnError(err, "initDB : create table obj_user")
_, err = db.Exec(`CREATE TABLE obj_guild ( _, err = db.Exec(`CREATE TABLE obj_guild (
@ -87,7 +87,7 @@ func initDB() {
,chat_id BIGINT NOT NULL ,chat_id BIGINT NOT NULL
,deposit_chat_id BIGINT NOT NULL ,deposit_chat_id BIGINT 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=utf8 COLLATE utf8_unicode_ci;`) ) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table obj_guild") failOnError(err, "initDB : create table obj_guild")
_, err = db.Exec(`CREATE TABLE obj_msg ( _, err = db.Exec(`CREATE TABLE obj_msg (
@ -100,7 +100,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=utf8 COLLATE utf8_unicode_ci;`) ) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table obj_msg") failOnError(err, "initDB : create table obj_msg")
_, err = db.Exec(`CREATE TABLE obj_msg_report ( _, err = db.Exec(`CREATE TABLE obj_msg_report (
@ -114,7 +114,7 @@ func initDB() {
,stamina TINYINT NOT NULL ,stamina TINYINT NOT NULL
,crit TINYINT NOT NULL ,crit TINYINT 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=utf8 COLLATE utf8_unicode_ci;`) ) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table obj_msg_report") failOnError(err, "initDB : create table obj_msg_report")
_, err = db.Exec(`INSERT INTO code_obj_type (id, intl_id, name) _, err = db.Exec(`INSERT INTO code_obj_type (id, intl_id, name)