| 1 | -- SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | -- |
| 3 | -- Add a `kind` discriminator to user_ssh_keys so callers can register |
| 4 | -- a key for git authentication (authorized-keys lookup) or for git |
| 5 | -- commit signing without conflating the two intents. |
| 6 | -- |
| 7 | -- Pre-existing rows are git-auth keys (the only kind shithub recognised |
| 8 | -- through S07-S16); we backfill `authentication` and let the check |
| 9 | -- constraint enforce the closed set going forward. |
| 10 | -- |
| 11 | -- The /api/v1/user/keys REST surface (S50 §1) returns rows filtered to |
| 12 | -- `authentication` by default to mirror GitHub's /user/keys shape; the |
| 13 | -- signing surface lands behind /user/ssh_signing_keys when a CLI sprint |
| 14 | -- consumes it. |
| 15 | |
| 16 | -- +goose Up |
| 17 | ALTER TABLE user_ssh_keys |
| 18 | ADD COLUMN kind text NOT NULL DEFAULT 'authentication' |
| 19 | CHECK (kind IN ('authentication', 'signing')); |
| 20 | |
| 21 | CREATE INDEX user_ssh_keys_user_id_kind_idx |
| 22 | ON user_ssh_keys (user_id, kind, created_at DESC); |
| 23 | |
| 24 | -- +goose Down |
| 25 | DROP INDEX IF EXISTS user_ssh_keys_user_id_kind_idx; |
| 26 | ALTER TABLE user_ssh_keys DROP COLUMN IF EXISTS kind; |
| 27 |