Skip to content

Commit 4983f34

Browse files
committed
fix migration hash format
1 parent 20a3f49 commit 4983f34

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/shared/migrations/20250214140307.sql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
CREATE OR REPLACE FUNCTION hex_to_sha256(hex_str text, prefix text) RETURNS text AS $$
33
DECLARE
44
bytes bytea;
5+
base64_hash text;
56
BEGIN
67
-- Remove the prefix and convert remaining hex to bytes
78
bytes := decode(substring(hex_str from length(prefix) + 1), 'hex');
8-
-- Return SHA256 hash as base64 string
9-
RETURN encode(sha256(bytes), 'base64');
9+
-- Get base64 hash and remove padding
10+
base64_hash := rtrim(encode(sha256(bytes), 'base64'), '=');
11+
-- Return SHA256 hash with $sha256$ prefix and base64-encoded hash without padding
12+
RETURN '$sha256$' || base64_hash;
1013
END;
1114
$$ LANGUAGE plpgsql;
1215

0 commit comments

Comments
 (0)