40_advance_url_settings.up.sql 841 B

123456789101112131415161718192021
  1. BEGIN;
  2. ALTER table public_collection_tokens
  3. ADD COLUMN IF NOT EXISTS pw_hash TEXT,
  4. ADD COLUMN IF NOT EXISTS pw_nonce TEXT,
  5. ADD COLUMN IF NOT EXISTS mem_limit BIGINT,
  6. ADD COLUMN IF NOT EXISTS ops_limit BIGINT,
  7. ADD COLUMN IF NOT EXISTS enable_download bool DEFAULT TRUE,
  8. ADD COLUMN IF NOT EXISTS enable_comment bool DEFAULT FALSE;
  9. UPDATE public_collection_tokens
  10. SET enable_download = TRUE,
  11. enable_comment = FALSE;
  12. ALTER TABLE public_collection_tokens
  13. ALTER COLUMN enable_download SET NOT NULL,
  14. ALTER COLUMN enable_comment SET NOT NULL;
  15. ALTER TABLE public_collection_tokens
  16. ADD CONSTRAINT pct_pw_state_constraint CHECK ( (pw_hash is NULL and pw_nonce is NULL) or
  17. (pw_hash is NOT NULL and pw_nonce is NOT NULL));
  18. COMMIT;