From c95bea473be235cbd7ce40e177da205159928b8f Mon Sep 17 00:00:00 2001 From: Michael Woolnough Date: Wed, 30 Oct 2024 09:49:02 +0000 Subject: [PATCH] Additional SQL init commands. --- server/analytics.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/analytics.go b/server/analytics.go index f389d23..f4555e5 100644 --- a/server/analytics.go +++ b/server/analytics.go @@ -33,12 +33,15 @@ func (s *Server) InitAnalyticsDB(dbPath string) error { db.SetMaxOpenConns(1) - for _, table := range [...]string{ + for _, cmd := range [...]string{ + `PRAGMA JOURNAL_MODE = DELETE;`, `CREATE TABLE IF NOT EXISTS [events] (user TEXT, session TEXT, state TEXT, time INTEGER)`, `CREATE INDEX IF NOT EXISTS username ON [events] (user)`, `CREATE INDEX IF NOT EXISTS sessionID ON [events] (session)`, + `CREATE INDEX IF NOT EXISTS eventTime ON [events] (time)`, + `VACUUM;`, } { - if _, err = db.Exec(table); err != nil { + if _, err = db.Exec(cmd); err != nil { return err } }