Skip to content

Commit edb5e3a

Browse files
authored
Merge pull request #609 from dzcode-io/switch-to-postgres
feat: Switch to postgres
2 parents 869676a + 70275a4 commit edb5e3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+691
-648
lines changed

.github/workflows/ci.reusable.lighthouse.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,5 @@ jobs:
108108
path: ./web/.lighthouseci
109109
- name: "Get current time"
110110
run: echo "LHCI_BUILD_CONTEXT__COMMIT_TIME=$(date '+%Y-%m-%d %H:%M:%S %z')" >> $GITHUB_ENV
111-
- run: npx lerna run lh:upload --scope "@dzcode.io/web"
111+
# @TODO-ZM: upload to grafana instead of lhci-server
112+
# - run: npx lerna run lh:upload --scope "@dzcode.io/web"

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ coverage
1818
# api
1919
api/oracle-cloud/build
2020
api/fetch_cache
21-
api/sqlite_db
21+
api/postgres_db
2222
api/nodemon.json
2323

2424
# web

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Make sure you have:
2525

2626
- [Git](https://git-scm.com/)
2727
- [Nodejs](https://nodejs.org/) version 20 or higher (we recommend using [volta](https://docs.volta.sh/guide/getting-started) over plain install or [nvm](https://github.com/nvm-sh/nvm))
28+
- [Docker](https://www.docker.com/) installed and running.
2829

2930
### Run it locally
3031

api/db/migrations/0000_melodic_shotgun.sql

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
CREATE TABLE IF NOT EXISTS "contributions" (
2+
"id" text PRIMARY KEY NOT NULL,
3+
"record_imported_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL,
4+
"title" text NOT NULL,
5+
"updated_at" text NOT NULL,
6+
"url" text NOT NULL,
7+
"type" text NOT NULL,
8+
"run_id" text NOT NULL,
9+
"activity_count" integer NOT NULL,
10+
"repository_id" text NOT NULL,
11+
"contributor_id" text NOT NULL,
12+
CONSTRAINT "contributions_url_unique" UNIQUE("url")
13+
);
14+
--> statement-breakpoint
15+
CREATE TABLE IF NOT EXISTS "contributor_repository_relation" (
16+
"contributor_id" text NOT NULL,
17+
"repository_id" text NOT NULL,
18+
"record_imported_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL,
19+
"run_id" text DEFAULT 'initial-run-id' NOT NULL,
20+
"score" integer NOT NULL,
21+
CONSTRAINT "contributor_repository_relation_pk" PRIMARY KEY("contributor_id","repository_id")
22+
);
23+
--> statement-breakpoint
24+
CREATE TABLE IF NOT EXISTS "contributors" (
25+
"id" text PRIMARY KEY NOT NULL,
26+
"record_imported_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL,
27+
"run_id" text DEFAULT 'initial-run-id' NOT NULL,
28+
"name" text NOT NULL,
29+
"username" text NOT NULL,
30+
"url" text NOT NULL,
31+
"avatar_url" text NOT NULL,
32+
CONSTRAINT "contributors_url_unique" UNIQUE("url")
33+
);
34+
--> statement-breakpoint
35+
CREATE TABLE IF NOT EXISTS "projects" (
36+
"id" text PRIMARY KEY NOT NULL,
37+
"record_imported_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL,
38+
"name" text NOT NULL,
39+
"run_id" text DEFAULT 'initial-run-id' NOT NULL
40+
);
41+
--> statement-breakpoint
42+
CREATE TABLE IF NOT EXISTS "repositories" (
43+
"id" text PRIMARY KEY NOT NULL,
44+
"record_imported_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL,
45+
"provider" text NOT NULL,
46+
"owner" text NOT NULL,
47+
"name" text NOT NULL,
48+
"run_id" text DEFAULT 'initial-run-id' NOT NULL,
49+
"project_id" text NOT NULL,
50+
"stars" integer NOT NULL,
51+
CONSTRAINT "repositories_provider_owner_name_unique" UNIQUE("provider","owner","name")
52+
);
53+
--> statement-breakpoint
54+
DO $$ BEGIN
55+
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;
56+
EXCEPTION
57+
WHEN duplicate_object THEN null;
58+
END $$;
59+
--> statement-breakpoint
60+
DO $$ BEGIN
61+
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;
62+
EXCEPTION
63+
WHEN duplicate_object THEN null;
64+
END $$;
65+
--> statement-breakpoint
66+
DO $$ BEGIN
67+
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;
68+
EXCEPTION
69+
WHEN duplicate_object THEN null;
70+
END $$;
71+
--> statement-breakpoint
72+
DO $$ BEGIN
73+
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;
74+
EXCEPTION
75+
WHEN duplicate_object THEN null;
76+
END $$;
77+
--> statement-breakpoint
78+
DO $$ BEGIN
79+
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;
80+
EXCEPTION
81+
WHEN duplicate_object THEN null;
82+
END $$;

0 commit comments

Comments
 (0)