Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions internal/session/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,24 +174,19 @@
}

// columnExists checks if a column exists in a table.
func (s *Store) columnExists(table, column string) (bool, error) {

Check failure on line 177 in internal/session/store.go

View workflow job for this annotation

GitHub Actions / check-sizes

syntax error: unexpected name string in argument list; possibly missing comma or )
rows, err := s.db.Query(fmt.Sprintf("PRAGMA table_info(%s)", table))
if err != nil {
return false, fmt.Errorf("failed to inspect %s schema: %w", table, err)
}
defer func() { _ = rows.Close() }()

for rows.Next() {
var cid int
var name, typ string
var notNull, pk int
var defaultValue interface{}
if err := rows.Scan(&cid, &name, &typ, &notNull, &defaultValue, &pk); err != nil {
return false, fmt.Errorf("failed to scan %s schema: %w", table, err)
}
if name == column {
return true, nil
}
if err := s.ensureColumn("sessions", "audit_hash", "TEXT"); err != nil {
return err
}
if err := s.ensureColumn("sessions", "audit_signature", "TEXT"); err != nil {
return err
}
if err := s.ensureColumn("sessions", "previous_session_hash", "TEXT"); err != nil {
return err
}
if err := rows.Err(); err != nil {
return false, err
Expand Down
Loading