Skip to content

Add API key database objects#21

Merged
djthorpe merged 5 commits into
mainfrom
djt/0420/apikey
Apr 20, 2026
Merged

Add API key database objects#21
djthorpe merged 5 commits into
mainfrom
djt/0420/apikey

Conversation

@djthorpe
Copy link
Copy Markdown
Member

This pull request updates the authentication schema by introducing a new apikey table to support API key management, along with an associated notification trigger. It also removes the previously used session refresh column migration logic. The most important changes are:

API Key Management:

  • Added a new apikey table (auth.apikey) with fields for hash, user, name, created_at, modified_at, and expires_at to support storing and managing API keys. (auth/schema/objects.sql, auth/schema/objects.sqlL44-R59)
  • Created an index on the user column of the new apikey table to optimize lookups by user. (auth/schema/objects.sql, auth/schema/objects.sqlL44-R59)

Notification Triggers:

  • Added a trigger (apikey_table_changes_notify) on the apikey table to notify on insert, update, or delete operations, ensuring that changes to API keys are tracked and can be responded to by other parts of the system. (auth/schema/objects.sql, auth/schema/objects.sqlR140-R148)

Session Table Migration Cleanup:

  • Removed the migration block that added and initialized refresh_expires_at and refresh_counter columns in the session table, indicating these columns are now assumed to be present in the base schema. (auth/schema/objects.sql, auth/schema/objects.sqlL44-R59)

@djthorpe djthorpe self-assigned this Apr 20, 2026
Copilot AI review requested due to automatic review settings April 20, 2026 10:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the auth database schema to support API key storage and change notifications, while removing a previously included schema-migration block for session refresh columns.

Changes:

  • Added a new auth.apikey table (with a user lookup index) for API key metadata.
  • Added a statement-level notification trigger for auth.apikey to integrate with the existing notify_table() mechanism.
  • Removed the idempotent migration block that added/backfilled session.refresh_expires_at and session.refresh_counter.

Comment thread auth/schema/objects.sql
@djthorpe djthorpe merged commit 2aa6fe4 into main Apr 20, 2026
3 checks passed
@djthorpe djthorpe deleted the djt/0420/apikey branch April 20, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants