Skip to content

Commit 6e56e55

Browse files
fix: Revert enc/dec function to the previous state, no need to make them trackable by Hasura
1 parent f5fd7a2 commit 6e56e55

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

memory-store/migrations/000042_add_api_keys.down.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BEGIN;
22

3-
-- Drop helper functions (now using RETURNS TABLE syntax)
3+
-- Drop helper functions
44
DROP FUNCTION IF EXISTS decrypt_api_key(BYTEA, TEXT);
55
DROP FUNCTION IF EXISTS encrypt_api_key(TEXT, TEXT);
66

memory-store/migrations/000042_add_api_keys.up.sql

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,28 @@ CREATE INDEX IF NOT EXISTS idx_api_keys_metadata ON api_keys USING gin(metadata)
4343
CREATE INDEX IF NOT EXISTS idx_api_keys_deleted_at ON api_keys(deleted_at) WHERE deleted_at IS NULL;
4444

4545
-- Helper functions for encryption/decryption (following secrets pattern)
46-
-- Modified to return TABLE so they can be tracked by Hasura
4746
CREATE OR REPLACE FUNCTION encrypt_api_key(
4847
p_value TEXT,
4948
p_key TEXT
50-
) RETURNS TABLE(encrypted_value BYTEA) AS $$
49+
) RETURNS BYTEA AS $$
5150
BEGIN
52-
RETURN QUERY SELECT
53-
pgp_sym_encrypt(
54-
p_value,
55-
p_key,
56-
'cipher-algo=aes256'
57-
);
51+
RETURN pgp_sym_encrypt(
52+
p_value,
53+
p_key,
54+
'cipher-algo=aes256'
55+
);
5856
END;
5957
$$ LANGUAGE plpgsql SECURITY DEFINER;
6058

6159
CREATE OR REPLACE FUNCTION decrypt_api_key(
6260
p_encrypted_value BYTEA,
6361
p_key TEXT
64-
) RETURNS TABLE(decrypted_value TEXT) AS $$
62+
) RETURNS TEXT AS $$
6563
BEGIN
66-
RETURN QUERY SELECT
67-
pgp_sym_decrypt(
68-
p_encrypted_value,
69-
p_key
70-
);
64+
RETURN pgp_sym_decrypt(
65+
p_encrypted_value,
66+
p_key
67+
);
7168
END;
7269
$$ LANGUAGE plpgsql SECURITY DEFINER;
7370

0 commit comments

Comments
 (0)