68_add_locker_changes.up.sql 686 B

12345678910111213141516171819202122
  1. ALTER TYPE app ADD VALUE 'locker';
  2. -- Alter the column to make it non-null
  3. ALTER TABLE collections ADD COLUMN app app DEFAULT 'photos';
  4. -- Update the existing app that are null to default ("photos") and make it non null.
  5. UPDATE collections SET app = 'photos' WHERE app IS NULL;
  6. -- Alter the column to make it non-null
  7. ALTER TABLE collections ALTER COLUMN app SET NOT NULL;
  8. -- Create a new unique index for uncategorized collections
  9. CREATE UNIQUE INDEX IF NOT EXISTS collections_uncategorized_constraint_index_v2 ON collections (owner_id, app)
  10. WHERE (type = 'uncategorized');
  11. -- Drop the older index if it exists
  12. DROP INDEX IF EXISTS collections_uncategorized_constraint_index;