0056_service_badges.sql 1.2 KB

12345678910111213141516171819202122232425262728
  1. -- Standard project-scoped service badges: one badge → one product wall.
  2. -- db = Doltgres, s3 = MinIO/S3, auth = SuperTokens-style M2M, pay = reserved.
  3. -- Doltgres-safe: no DO $$ exception blocks (unsupported on wire path).
  4. CREATE TABLE IF NOT EXISTS "service_badges" (
  5. "id" text PRIMARY KEY NOT NULL,
  6. "project_id" text NOT NULL,
  7. "product" text NOT NULL,
  8. "name" text NOT NULL,
  9. "role" text DEFAULT 'developer' NOT NULL,
  10. "prefix" text NOT NULL,
  11. "suffix" varchar(4) NOT NULL,
  12. "hash" text,
  13. "storage_key_id" text,
  14. "m2m_client_id" text,
  15. "created_by" text,
  16. "last_used_at" timestamp with time zone,
  17. "expires_at" timestamp with time zone,
  18. "created_at" timestamp with time zone DEFAULT now() NOT NULL,
  19. "revoked_at" timestamp with time zone
  20. );
  21. --> statement-breakpoint
  22. CREATE UNIQUE INDEX IF NOT EXISTS "service_badges_hash_idx" ON "service_badges" ("hash");
  23. --> statement-breakpoint
  24. CREATE INDEX IF NOT EXISTS "service_badges_project_product_idx" ON "service_badges" ("project_id","product");
  25. --> statement-breakpoint
  26. CREATE INDEX IF NOT EXISTS "service_badges_m2m_client_idx" ON "service_badges" ("m2m_client_id");
  27. --> statement-breakpoint
  28. CREATE INDEX IF NOT EXISTS "service_badges_storage_key_idx" ON "service_badges" ("storage_key_id");