| 1 | CREATE TABLE "repository_contribution" ( |
| 2 | "repository_id" text NOT NULL, |
| 3 | "author_email" text NOT NULL, |
| 4 | "day" date NOT NULL, |
| 5 | "author_name" text NOT NULL, |
| 6 | "author_id" text, |
| 7 | "commits" integer DEFAULT 0 NOT NULL, |
| 8 | CONSTRAINT "repository_contribution_repository_id_author_email_day_pk" PRIMARY KEY("repository_id","author_email","day") |
| 9 | ); |
| 10 | --> statement-breakpoint |
| 11 | CREATE TABLE "repository_contribution_index" ( |
| 12 | "repository_id" text NOT NULL, |
| 13 | "indexed_commit_sha" text NOT NULL, |
| 14 | "updated_at" timestamp with time zone DEFAULT now() NOT NULL, |
| 15 | CONSTRAINT "repository_contribution_index_repository_id_pk" PRIMARY KEY("repository_id") |
| 16 | ); |
| 17 | --> statement-breakpoint |
| 18 | ALTER TABLE "repository_contribution" ADD CONSTRAINT "repository_contribution_repository_id_repository_id_fk" FOREIGN KEY ("repository_id") REFERENCES "public"."repository"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint |
| 19 | ALTER TABLE "repository_contribution" ADD CONSTRAINT "repository_contribution_author_id_user_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint |
| 20 | ALTER TABLE "repository_contribution_index" ADD CONSTRAINT "repository_contribution_index_repository_id_repository_id_fk" FOREIGN KEY ("repository_id") REFERENCES "public"."repository"("id") ON DELETE cascade ON UPDATE no action; |