Skip to content

Commit 5ba5a5d

Browse files
author
Ignacio Van Droogenbroeck
committed
Add migration for expires_at column in api_tokens
Existing databases created by Python don't have the expires_at column. This adds a migration that runs ALTER TABLE to add the column if missing.
1 parent 37bcf90 commit 5ba5a5d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

internal/auth/auth.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ func (am *AuthManager) initDB() error {
125125
return fmt.Errorf("failed to create index: %w", err)
126126
}
127127

128+
// Migration: add expires_at column if it doesn't exist (for databases created by Python)
129+
_, err = am.db.Exec(`ALTER TABLE api_tokens ADD COLUMN expires_at TIMESTAMP`)
130+
if err != nil {
131+
// Ignore "duplicate column" error - column already exists
132+
if !strings.Contains(err.Error(), "duplicate column") {
133+
am.logger.Debug().Err(err).Msg("expires_at column already exists or migration failed")
134+
}
135+
}
136+
128137
return nil
129138
}
130139

0 commit comments

Comments
 (0)