games inits itself
This commit is contained in:
@@ -1,9 +1,29 @@
|
||||
package main
|
||||
|
||||
import "context"
|
||||
|
||||
type Games struct {
|
||||
db DB
|
||||
}
|
||||
|
||||
func NewGames(db DB) Games {
|
||||
return Games{db: db}
|
||||
func NewGames(ctx context.Context, db DB) (Games, error) {
|
||||
err := db.Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
uuid TEXT,
|
||||
name TEXT
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS games (
|
||||
uuid TEXT
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS players (
|
||||
user_uuid TEXT,
|
||||
game_uuid TEXT
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS events (
|
||||
game_uuid TEXT,
|
||||
timestamp DATETIME,
|
||||
payload TEXT
|
||||
);
|
||||
`)
|
||||
return Games{db: db}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user