feat(coderd/database): add value_key_id column to user_secrets for encryption (#23997)

Add a nullable `value_key_id` column to the `user_secrets` table with a
foreign key to `dbcrypt_keys`. This is the column dbcrypt uses to track
which encryption key encrypted a given secret's value. This is required
for encryption of user secret values.

The column was missing from the original migration (000357).
This commit is contained in:
Zach
2026-04-02 15:40:32 -06:00
committed by GitHub
parent 0cb942aab2
commit 990c006f28
6 changed files with 34 additions and 15 deletions
@@ -0,0 +1,3 @@
ALTER TABLE user_secrets
DROP CONSTRAINT user_secrets_value_key_id_fkey,
DROP COLUMN value_key_id;
@@ -0,0 +1,5 @@
ALTER TABLE user_secrets
ADD COLUMN value_key_id TEXT;
ALTER TABLE ONLY user_secrets
ADD CONSTRAINT user_secrets_value_key_id_fkey FOREIGN KEY (value_key_id) REFERENCES dbcrypt_keys(active_key_digest);