0005_majestic_nightcrawler.sql 1.3 KB

12345678910111213141516171819
  1. CREATE TABLE "project_invitations" (
  2. "id" text PRIMARY KEY NOT NULL,
  3. "project_id" text NOT NULL,
  4. "email" text NOT NULL,
  5. "role" text DEFAULT 'developer' NOT NULL,
  6. "token_hash" text NOT NULL,
  7. "invited_by" text,
  8. "expires_at" timestamp with time zone NOT NULL,
  9. "accepted_at" timestamp with time zone,
  10. "revoked_at" timestamp with time zone,
  11. "created_at" timestamp with time zone DEFAULT now() NOT NULL
  12. );
  13. --> statement-breakpoint
  14. ALTER TABLE "users" ADD COLUMN "is_admin" boolean DEFAULT false NOT NULL;--> statement-breakpoint
  15. ALTER TABLE "users" ADD COLUMN "suspended_at" timestamp with time zone;--> statement-breakpoint
  16. ALTER TABLE "project_invitations" ADD CONSTRAINT "project_invitations_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
  17. ALTER TABLE "project_invitations" ADD CONSTRAINT "project_invitations_invited_by_users_id_fk" FOREIGN KEY ("invited_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
  18. CREATE UNIQUE INDEX "project_invitations_project_email_idx" ON "project_invitations" USING btree ("project_id","email");--> statement-breakpoint
  19. CREATE UNIQUE INDEX "project_invitations_token_idx" ON "project_invitations" USING btree ("token_hash");