Files
windmill/backend/migrations/20260909085548_add_deployment_metadata_primary_key.up.sql
Ruben FiszelandClaude Opus 5 e62bfdcd8c fix: give every table a primary key so the db can be logically replicated (#11036)
* fix: give every table a primary key so the db can be logically replicated

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WS9iNfYQiLJNuBnxysBzi

* fix: tighten replicability guard and trim migration comments

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WS9iNfYQiLJNuBnxysBzi

* fix: split deployment_metadata into its own primary-key migration

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WS9iNfYQiLJNuBnxysBzi

* docs: correct the partial-index predicate note after the deployment_metadata split

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WS9iNfYQiLJNuBnxysBzi

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-10 18:42:24 +00:00

14 lines
728 B
SQL

-- The sixth of the seven; why any of them need a key is in
-- 20260909052532_add_missing_primary_keys.
--
-- Kept out of that migration because it is the one table in the set with no retention
-- sweep -- rows accumulate per deployed script hash, flow version and app version for
-- the life of the instance -- so on an instance that upgrades after years of deploys
-- its ACCESS EXCLUSIVE rewrite is the one that could hold the others locked.
--
-- No natural key: each row is a script, flow OR app deployment, and the three unique
-- indexes are partial on exactly that split, so none of them covers every row.
ALTER TABLE deployment_metadata
ADD COLUMN IF NOT EXISTS id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY;