Add support for cmdline matching and add basic interpreter support

This commit is contained in:
Patrick Pacher
2022-10-10 15:28:57 +02:00
committed by Daniel
parent b3007b71db
commit 77c0d954a9
11 changed files with 338 additions and 66 deletions

View File

@@ -193,6 +193,20 @@ func (db *Database) ApplyMigrations() error {
return fmt.Errorf("failed to create schema: %w", err)
}
// create a few indexes
indexes := []string{
`CREATE INDEX profile_id_index ON %s (profile)`,
`CREATE INDEX started_time_index ON %s (strftime('%%s', started)+0)`,
`CREATE INDEX started_ended_time_index ON %s (strftime('%%s', started)+0, strftime('%%s', ended)+0) WHERE ended IS NOT NULL`,
}
for _, idx := range indexes {
stmt := fmt.Sprintf(idx, db.Schema.Name)
if err := sqlitex.ExecuteTransient(db.writeConn, stmt, nil); err != nil {
return fmt.Errorf("failed to create index: %q: %w", idx, err)
}
}
return nil
}