Submatter/packages/database/migrations/0012_uneven_captain_stacy.sql

19 lines
1 KiB
MySQL
Raw Permalink Normal View History

CREATE TABLE "connected_repos" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"workspace_id" uuid NOT NULL,
"display_name" varchar(200) NOT NULL,
"git_remote_url" text NOT NULL,
"forge_type" varchar(40) NOT NULL,
"api_base_url" text NOT NULL,
"owner" varchar(200) NOT NULL,
"repo_name" varchar(200) NOT NULL,
"default_branch" varchar(200),
"token_env_var" varchar(120),
"metadata" jsonb,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "connected_repos" ADD CONSTRAINT "connected_repos_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "connected_repos_workspace_id_idx" ON "connected_repos" USING btree ("workspace_id");--> statement-breakpoint
CREATE UNIQUE INDEX "connected_repos_workspace_repo_unique" ON "connected_repos" USING btree ("workspace_id","api_base_url","owner","repo_name");