ALTER TABLE "repositories"
ADD COLUMN IF NOT EXISTS "is_template" boolean NOT NULL DEFAULT false;
CREATE INDEX IF NOT EXISTS "repos_is_template" ON "repositories" ("is_template") WHERE "is_template" = true;
CREATE TABLE IF NOT EXISTS "repo_transfers" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"repository_id" uuid NOT NULL,
"from_owner_id" uuid NOT NULL,
"from_org_id" uuid,
"to_owner_id" uuid NOT NULL,
"to_org_id" uuid,
"initiated_by" uuid NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "repo_transfers_repo_fk" FOREIGN KEY ("repository_id") REFERENCES "repositories"("id") ON DELETE cascade,
CONSTRAINT "repo_transfers_init_fk" FOREIGN KEY ("initiated_by") REFERENCES "users"("id") ON DELETE cascade
);
CREATE INDEX IF NOT EXISTS "repo_transfers_repo" ON "repo_transfers" ("repository_id", "created_at");
|