Skip to content

Commit

Permalink
build: update public beta rename migration to be idempotent
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Sep 20, 2024
1 parent 09acd76 commit 0cd71fa
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/backend/migrations/005-rename-public-beta.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
-- Start a transaction
BEGIN;

UPDATE public.organisations
SET
name = 'HOTOSM',
slug = 'hotosm',
description = 'Humanitarian OpenStreetMap Team'
WHERE slug = 'fmtm-public-beta';
-- Check if the organization with the new name 'HOTOSM' already exists
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM public.organisations WHERE slug = 'hotosm'
) THEN
-- If 'HOTOSM' does not exist, update the organisation
UPDATE public.organisations
SET
name = 'HOTOSM',
slug = 'hotosm',
description = 'Humanitarian OpenStreetMap Team'
WHERE slug = 'fmtm-public-beta';
END IF;
END $$;

-- Commit the transaction
COMMIT;

0 comments on commit 0cd71fa

Please sign in to comment.