04__resource_public_id.sql 429 B

12345678910111213141516171819
  1. ALTER TABLE
  2. resource
  3. ADD
  4. COLUMN public_id TEXT NOT NULL DEFAULT '';
  5. -- TODO(steven): remove this in next release.
  6. CREATE UNIQUE INDEX resource_id_public_id_unique_index ON resource (id, public_id);
  7. UPDATE
  8. resource
  9. SET
  10. public_id = printf (
  11. '%s-%s-%s-%s-%s',
  12. lower(hex(randomblob(4))),
  13. lower(hex(randomblob(2))),
  14. lower(hex(randomblob(2))),
  15. lower(hex(randomblob(2))),
  16. lower(hex(randomblob(6)))
  17. );