Remove "Cairn University" Account from MOSAIC Organization

Remove "Cairn University" Account from MOSAIC Organization

Overview

This migration script removes the account with the name "Cairn University" from the default MOSAIC organization's accounts array. The script only affects the MOSAIC organization (identified by code = 'MOSAIC') and only runs if the account actually exists. All other accounts remain untouched.

Manual Execution

 

  1. Run the SQL, replacing <tenant> with the actual tenant ID (e.g., diku):

    UPDATE <tenant>_mod_organizations_storage.organizations SET jsonb = jsonb_set( jsonb, '{accounts}', ( SELECT COALESCE(jsonb_agg(account), '[]'::jsonb) FROM jsonb_array_elements(jsonb -> 'accounts') AS account WHERE account ->> 'name' != 'Cairn University' ) ) WHERE jsonb ->> 'code' = 'MOSAIC' AND jsonb -> 'accounts' @> '[{"name": "Cairn University"}]';
  2. Verify the account was removed:

    SELECT jsonb -> 'accounts' FROM <tenant>_mod_organizations_storage.organizations WHERE jsonb ->> 'code' = 'MOSAIC';