Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions pkg/coredata/migrations/20260710T152544Z.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,23 @@
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.

ALTER TABLE trust_centers
RENAME COLUMN page_title TO title;
-- Idempotent: no-op when page_title was already renamed or never added.
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'trust_centers'
AND column_name = 'page_title'
) AND NOT EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'trust_centers'
AND column_name = 'title'
) THEN
ALTER TABLE trust_centers
RENAME COLUMN page_title TO title;
END IF;
END $$;
43 changes: 34 additions & 9 deletions pkg/coredata/migrations/20260721T133736Z.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,37 @@
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.

-- title is the full home page heading. Rows that still store the org name as a
-- fragment (the pre-migration default) are backfilled to the English hero copy
-- the UI previously rendered via i18n ("Compliance at {{name}}.").
UPDATE trust_centers tc
SET title = 'Compliance at ' || o.name || '.',
updated_at = NOW()
FROM organizations o
WHERE tc.organization_id = o.id
AND tc.title = o.name;
-- title (or page_title, if the rename was skipped) is the full home page
-- heading. Rows that still store the org name as a fragment (the
-- pre-migration default) are backfilled to the English hero copy the UI
-- previously rendered via i18n ("Compliance at {{name}}.").
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'trust_centers'
AND column_name = 'title'
) THEN
UPDATE trust_centers tc
SET title = 'Compliance at ' || o.name || '.',
updated_at = NOW()
FROM organizations o
WHERE tc.organization_id = o.id
AND tc.title = o.name;
ELSIF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'trust_centers'
AND column_name = 'page_title'
) THEN
UPDATE trust_centers tc
SET page_title = 'Compliance at ' || o.name || '.',
updated_at = NOW()
FROM organizations o
WHERE tc.organization_id = o.id
AND tc.page_title = o.name;
END IF;
END $$;
7 changes: 6 additions & 1 deletion pkg/coredata/migrations/20260721T165706Z.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@ WHERE tc.organization_id = o.id;
ALTER TABLE trust_centers
ALTER COLUMN entity_name DROP DEFAULT;

-- Drop both names: installs that applied page_title but skipped the
-- rename still have page_title; fully renamed installs have title.
ALTER TABLE trust_centers
DROP COLUMN title;
DROP COLUMN IF EXISTS title;

ALTER TABLE trust_centers
DROP COLUMN IF EXISTS page_title;
82 changes: 82 additions & 0 deletions pkg/coredata/migrations/20260730T132804Z.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
-- Copyright (c) 2026 Probo Inc <hello@probo.com>.
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.

-- trust_centers branding briefly lived as page_title, then title, then
-- entity_name. Inserts only populate entity_name; leftover NOT NULL
-- page_title/title columns make organization create fail with
-- SQLSTATE 23502. Ensure entity_name is present and drop the obsolete
-- columns for installs that got stuck between those renames.

DO $$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'trust_centers'
AND column_name = 'entity_name'
) THEN
ALTER TABLE trust_centers
ADD COLUMN entity_name TEXT NOT NULL DEFAULT '';

UPDATE trust_centers tc
SET entity_name = o.name
FROM organizations o
WHERE tc.organization_id = o.id
AND tc.entity_name = '';

IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'trust_centers'
AND column_name = 'page_title'
) THEN
UPDATE trust_centers
SET entity_name = page_title
WHERE entity_name = ''
AND page_title IS NOT NULL
AND page_title <> '';
END IF;

IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'trust_centers'
AND column_name = 'title'
) THEN
UPDATE trust_centers
SET entity_name = title
WHERE entity_name = ''
AND title IS NOT NULL
AND title <> '';
END IF;

ALTER TABLE trust_centers
ALTER COLUMN entity_name DROP DEFAULT;
END IF;
END $$;

ALTER TABLE trust_centers
DROP COLUMN IF EXISTS page_title;

ALTER TABLE trust_centers
DROP COLUMN IF EXISTS title;
Loading