Skip to content

Commit

Permalink
Additional SQL init commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkw31 committed Oct 31, 2024
1 parent e4104fc commit 155cd2c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions server/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 155cd2c

Please sign in to comment.