-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #609 from dzcode-io/switch-to-postgres
feat: Switch to postgres
- Loading branch information
Showing
44 changed files
with
691 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
CREATE TABLE IF NOT EXISTS "contributions" ( | ||
"id" text PRIMARY KEY NOT NULL, | ||
"record_imported_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
"title" text NOT NULL, | ||
"updated_at" text NOT NULL, | ||
"url" text NOT NULL, | ||
"type" text NOT NULL, | ||
"run_id" text NOT NULL, | ||
"activity_count" integer NOT NULL, | ||
"repository_id" text NOT NULL, | ||
"contributor_id" text NOT NULL, | ||
CONSTRAINT "contributions_url_unique" UNIQUE("url") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "contributor_repository_relation" ( | ||
"contributor_id" text NOT NULL, | ||
"repository_id" text NOT NULL, | ||
"record_imported_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
"run_id" text DEFAULT 'initial-run-id' NOT NULL, | ||
"score" integer NOT NULL, | ||
CONSTRAINT "contributor_repository_relation_pk" PRIMARY KEY("contributor_id","repository_id") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "contributors" ( | ||
"id" text PRIMARY KEY NOT NULL, | ||
"record_imported_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
"run_id" text DEFAULT 'initial-run-id' NOT NULL, | ||
"name" text NOT NULL, | ||
"username" text NOT NULL, | ||
"url" text NOT NULL, | ||
"avatar_url" text NOT NULL, | ||
CONSTRAINT "contributors_url_unique" UNIQUE("url") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "projects" ( | ||
"id" text PRIMARY KEY NOT NULL, | ||
"record_imported_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
"name" text NOT NULL, | ||
"run_id" text DEFAULT 'initial-run-id' NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "repositories" ( | ||
"id" text PRIMARY KEY NOT NULL, | ||
"record_imported_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
"provider" text NOT NULL, | ||
"owner" text NOT NULL, | ||
"name" text NOT NULL, | ||
"run_id" text DEFAULT 'initial-run-id' NOT NULL, | ||
"project_id" text NOT NULL, | ||
"stars" integer NOT NULL, | ||
CONSTRAINT "repositories_provider_owner_name_unique" UNIQUE("provider","owner","name") | ||
); | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "contributions" ADD CONSTRAINT "contributions_repository_id_repositories_id_fk" FOREIGN KEY ("repository_id") REFERENCES "public"."repositories"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "contributions" ADD CONSTRAINT "contributions_contributor_id_contributors_id_fk" FOREIGN KEY ("contributor_id") REFERENCES "public"."contributors"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "contributor_repository_relation" ADD CONSTRAINT "contributor_repository_relation_contributor_id_contributors_id_fk" FOREIGN KEY ("contributor_id") REFERENCES "public"."contributors"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "contributor_repository_relation" ADD CONSTRAINT "contributor_repository_relation_repository_id_repositories_id_fk" FOREIGN KEY ("repository_id") REFERENCES "public"."repositories"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "repositories" ADD CONSTRAINT "repositories_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; |
Oops, something went wrong.