table creation order

This commit is contained in:
shoopea 2019-10-10 17:18:52 +08:00
parent 3ed8574e5b
commit ae4d207dc7

24
sql.go
View File

@ -82,6 +82,18 @@ func initDB() {
failOnError(err, "initDB : create table obj") failOnError(err, "initDB : create table obj")
log.Println("initDB : obj created ...") log.Println("initDB : obj created ...")
_, err = db.Exec(`CREATE TABLE obj_item (
obj_id BIGINT UNSIGNED NOT NULL
,intl_id VARCHAR(32)
,weight SMALLINT NOT NULL
,exchange TINYINT NOT NULL
,auction TINYINT NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY (intl_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_item")
log.Println("initDB : obj_item created ...")
_, err = db.Exec(`CREATE TABLE obj_castle ( _, err = db.Exec(`CREATE TABLE obj_castle (
obj_id BIGINT UNSIGNED NOT NULL obj_id BIGINT UNSIGNED NOT NULL
,logo VARCHAR(32) NOT NULL ,logo VARCHAR(32) NOT NULL
@ -314,18 +326,6 @@ func initDB() {
failOnError(err, "initDB : create table msg_rules_v") failOnError(err, "initDB : create table msg_rules_v")
log.Println("initDB : msg_rules created ...") log.Println("initDB : msg_rules created ...")
_, err = db.Exec(`CREATE TABLE obj_item (
obj_id BIGINT UNSIGNED NOT NULL
,intl_id VARCHAR(32)
,weight SMALLINT NOT NULL
,exchange TINYINT NOT NULL
,auction TINYINT NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY (intl_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_item")
log.Println("initDB : obj_item created ...")
_, err = db.Exec(`CREATE TABLE obj_tribute ( _, err = db.Exec(`CREATE TABLE obj_tribute (
obj_id BIGINT UNSIGNED NOT NULL obj_id BIGINT UNSIGNED NOT NULL
,user_id BIGINT UNSIGNED NOT NULL ,user_id BIGINT UNSIGNED NOT NULL