Update db initializer with proper column types
This commit is contained in:
parent
81ffdc0a74
commit
94dbee7c76
@ -22,10 +22,10 @@ func ConnectDatabase(dbConnString string) {
|
||||
|
||||
func InitializeDatabase() {
|
||||
_, err := Database.Query("CREATE TABLE IF NOT EXISTS users(" +
|
||||
"id bigint primary key," +
|
||||
"id varchar(30) primary key," +
|
||||
"banned bool not null default false," +
|
||||
"logging bool not null default true," +
|
||||
"steam_id bigint default NULL," +
|
||||
"steam_id varchar(30) NOT NULL DEFAULT ''," +
|
||||
"is_active bool not null default true," +
|
||||
"is_staff bool not null default false," +
|
||||
"is_admin bool not null default false" +
|
||||
@ -34,10 +34,11 @@ func InitializeDatabase() {
|
||||
fmt.Println(err)
|
||||
}
|
||||
_, err = Database.Query("CREATE TABLE IF NOT EXISTS guilds(" +
|
||||
"id bigint primary key," +
|
||||
"id varchar(30) primary key," +
|
||||
"welcome_message varchar(1000)," +
|
||||
"goodbye_message varchar(1000)," +
|
||||
"logging_channel bigint" +
|
||||
"logging_channel varchar(30) NOT NULL DEFAULT ''," +
|
||||
"welcome_channel varchar(30) NOT NULL DEFAULT ''" +
|
||||
")")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
@ -53,22 +54,22 @@ func InitializeDatabase() {
|
||||
"id serial primary key," +
|
||||
"tag varchar(100) not null unique," +
|
||||
"content varchar(1000) not null," +
|
||||
"creator bigint not null references users(id)," +
|
||||
"creator varchar(30) not null references users(id)," +
|
||||
"creation_time timestamp not null default NOW()," +
|
||||
"guild_id bigint not null" +
|
||||
"guild_id varchar(30) not null references guilds(id)" +
|
||||
")")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
_, err = Database.Query("CREATE TABLE IF NOT EXISTS x_users_guilds(" +
|
||||
"guild_id bigint not null references guilds(id)," +
|
||||
"user_id bigint not null references users(id)" +
|
||||
"guild_id varchar(30) not null references guilds(id)," +
|
||||
"user_id varchar(30) not null references users(id)" +
|
||||
")")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
_, err = Database.Query("CREATE TABLE IF NOT EXISTS x_guilds_prefixes(" +
|
||||
"guild_id bigint not null references guilds(id)," +
|
||||
"guild_id varchar(30) not null references guilds(id)," +
|
||||
"prefix_id int not null references prefixes(id)" +
|
||||
")")
|
||||
if err != nil {
|
||||
@ -78,14 +79,14 @@ func InitializeDatabase() {
|
||||
|
||||
func LoadTestData() {
|
||||
_, err := Database.Query("INSERT INTO users (id, banned, logging, steam_id, is_active, is_staff, is_admin) values " +
|
||||
"(351794468870946827, false, true, 76561198024193239, true, true, true)," +
|
||||
"(692908139506434065, false, true, NULL, true, false, false)," +
|
||||
"(396588996706304010, false, true, NULL, true, true, false)")
|
||||
"('351794468870946827', false, true, '76561198024193239', true, true, true)," +
|
||||
"('692908139506434065', false, true, '', true, false, false)," +
|
||||
"('396588996706304010', false, true, '', true, true, false)")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
_, err = Database.Query("INSERT INTO guilds (id, welcome_message, goodbye_message) VALUES " +
|
||||
"(265828729970753537, 'Hey there is someone new here.', 'Well fine then... Just leave without saying goodbye')")
|
||||
"('265828729970753537', 'Hey there is someone new here.', 'Well fine then... Just leave without saying goodbye')")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
@ -94,21 +95,21 @@ func LoadTestData() {
|
||||
fmt.Println(err)
|
||||
}
|
||||
_, err = Database.Query("INSERT INTO x_users_guilds (guild_id, user_id) VALUES " +
|
||||
"(265828729970753537, 351794468870946827)," +
|
||||
"(265828729970753537, 692908139506434065)," +
|
||||
"(265828729970753537, 396588996706304010)")
|
||||
"('265828729970753537', '351794468870946827')," +
|
||||
"('265828729970753537', '692908139506434065')," +
|
||||
"('265828729970753537', '396588996706304010')")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
_, err = Database.Query("INSERT INTO x_guilds_prefixes (guild_id, prefix_id) VALUES " +
|
||||
"(265828729970753537, 1)," +
|
||||
"(265828729970753537, 2)," +
|
||||
"(265828729970753537, 3)")
|
||||
"('265828729970753537', 1)," +
|
||||
"('265828729970753537', 2)," +
|
||||
"('265828729970753537', 3)")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
_, err = Database.Query("INSERT INTO tags (tag, content, creator, guild_id) VALUES " +
|
||||
"('test', 'This is a test of the tag system', 351794468870946827, 265828729970753537)")
|
||||
"('test', 'This is a test of the tag system', '351794468870946827', '265828729970753537')")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user