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 30, 2024
1 parent e978bba commit c95bea4
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 c95bea4

Please sign in to comment.