Files
pocket-id/backend/resources/migrations/postgres/20260718000000_freeze_config.up.sql
Alessandro (Ale) Segala 2cfbcb4b67 refactor: use actors for db configuration (#1604)
Co-authored-by: Claude <noreply@anthropic.com>
2026-07-20 08:48:05 +02:00

13 lines
595 B
SQL

-- Freeze the app configuration
-- Encode every row of the standalone config table as a single JSON object (mapping key -> value) and store it in the "kv" table under the "config_migrated" key
--
-- json_object_agg aggregates all rows into a JSON object
-- The "HAVING count(*) > 0" clause ensures that nothing is written to the "kv" table when the config table is empty
INSERT INTO kv ("key", "value")
SELECT 'config_migrated', json_object_agg("key", "value")::text
FROM app_config_variables
HAVING count(*) > 0;
-- Drop the now-frozen standalone config table
DROP TABLE app_config_variables;