mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
130 lines
No EOL
7.9 KiB
SQL
130 lines
No EOL
7.9 KiB
SQL
CREATE TABLE "agent_request_logs" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"agent_id" text NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"endpoint" text NOT NULL,
|
|
"method" text NOT NULL,
|
|
"status_code" integer NOT NULL,
|
|
"response_time_ms" integer NOT NULL,
|
|
"user_agent" text,
|
|
"ip_address" text,
|
|
"created_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "agents" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"display_name" text NOT NULL,
|
|
"description" text,
|
|
"is_active" integer DEFAULT 1 NOT NULL,
|
|
"last_used_at" timestamp,
|
|
"total_requests" integer DEFAULT 0 NOT NULL,
|
|
"created_by_user_id" text NOT NULL,
|
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "audit_logs" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"user_id" text NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"target_type" integer NOT NULL,
|
|
"target_id" text NOT NULL,
|
|
"new_value" jsonb NOT NULL,
|
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
"description" text NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "cloud_jobs" (
|
|
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "cloud_jobs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
|
|
"type" text NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"payload" jsonb NOT NULL,
|
|
"result" jsonb,
|
|
"error" text,
|
|
"slack_thread_ts" text,
|
|
"started_at" timestamp,
|
|
"completed_at" timestamp,
|
|
"created_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "organization_settings" (
|
|
"organization_id" text PRIMARY KEY NOT NULL,
|
|
"version" integer DEFAULT 1 NOT NULL,
|
|
"cloud_settings" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"default_settings" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"allow_list" jsonb DEFAULT '{"allowAll":true,"providers":{}}'::jsonb NOT NULL,
|
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "organizations" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"name" text NOT NULL,
|
|
"slug" text NOT NULL,
|
|
"image_url" text NOT NULL,
|
|
"entity" jsonb NOT NULL,
|
|
"last_sync_at" timestamp DEFAULT now() NOT NULL,
|
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "task_shares" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"task_id" text NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"created_by_user_id" text NOT NULL,
|
|
"share_token" text NOT NULL,
|
|
"visibility" text DEFAULT 'organization' NOT NULL,
|
|
"expires_at" timestamp,
|
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp DEFAULT now() NOT NULL,
|
|
CONSTRAINT "task_shares_share_token_unique" UNIQUE("share_token")
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "users" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text,
|
|
"organization_role" text,
|
|
"name" text NOT NULL,
|
|
"email" text NOT NULL,
|
|
"image_url" text NOT NULL,
|
|
"entity" jsonb NOT NULL,
|
|
"last_sync_at" timestamp DEFAULT now() NOT NULL,
|
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "agent_request_logs" ADD CONSTRAINT "agent_request_logs_agent_id_agents_id_fk" FOREIGN KEY ("agent_id") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "agent_request_logs" ADD CONSTRAINT "agent_request_logs_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "agents" ADD CONSTRAINT "agents_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "agents" ADD CONSTRAINT "agents_created_by_user_id_users_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "audit_logs" ADD CONSTRAINT "audit_logs_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "audit_logs" ADD CONSTRAINT "audit_logs_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "organization_settings" ADD CONSTRAINT "organization_settings_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "task_shares" ADD CONSTRAINT "task_shares_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "task_shares" ADD CONSTRAINT "task_shares_created_by_user_id_users_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "users" ADD CONSTRAINT "users_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "agent_request_logs_agent_id_idx" ON "agent_request_logs" USING btree ("agent_id");--> statement-breakpoint
|
|
CREATE INDEX "agent_request_logs_org_id_idx" ON "agent_request_logs" USING btree ("organization_id");--> statement-breakpoint
|
|
CREATE INDEX "agent_request_logs_created_at_idx" ON "agent_request_logs" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "agents_org_id_idx" ON "agents" USING btree ("organization_id");--> statement-breakpoint
|
|
CREATE INDEX "agents_active_idx" ON "agents" USING btree ("is_active") WHERE "agents"."is_active" = 1;--> statement-breakpoint
|
|
CREATE INDEX "agents_last_used_idx" ON "agents" USING btree ("last_used_at");--> statement-breakpoint
|
|
CREATE INDEX "audit_logs_user_id_idx" ON "audit_logs" USING btree ("user_id");--> statement-breakpoint
|
|
CREATE INDEX "audit_logs_organization_id_idx" ON "audit_logs" USING btree ("organization_id");--> statement-breakpoint
|
|
CREATE INDEX "audit_logs_target_idx" ON "audit_logs" USING btree ("target_type","target_id");--> statement-breakpoint
|
|
CREATE INDEX "audit_logs_created_at_idx" ON "audit_logs" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "organization_settings_created_at_idx" ON "organization_settings" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "organizations_slug_idx" ON "organizations" USING btree ("slug");--> statement-breakpoint
|
|
CREATE INDEX "organizations_created_at_idx" ON "organizations" USING btree ("created_at");--> statement-breakpoint
|
|
CREATE INDEX "task_shares_share_token_idx" ON "task_shares" USING btree ("share_token");--> statement-breakpoint
|
|
CREATE INDEX "task_shares_task_id_idx" ON "task_shares" USING btree ("task_id");--> statement-breakpoint
|
|
CREATE INDEX "task_shares_org_id_idx" ON "task_shares" USING btree ("organization_id");--> statement-breakpoint
|
|
CREATE INDEX "task_shares_expires_at_idx" ON "task_shares" USING btree ("expires_at");--> statement-breakpoint
|
|
CREATE INDEX "task_shares_created_by_user_id_idx" ON "task_shares" USING btree ("created_by_user_id");--> statement-breakpoint
|
|
CREATE INDEX "task_shares_visibility_idx" ON "task_shares" USING btree ("visibility");--> statement-breakpoint
|
|
CREATE INDEX "users_organization_id_idx" ON "users" USING btree ("organization_id");--> statement-breakpoint
|
|
CREATE INDEX "users_organization_role_idx" ON "users" USING btree ("organization_id","organization_role");--> statement-breakpoint
|
|
CREATE INDEX "users_email_idx" ON "users" USING btree ("email");--> statement-breakpoint
|
|
CREATE INDEX "users_created_at_idx" ON "users" USING btree ("created_at"); |