Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Switch to postgres #609

Merged
merged 20 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
72b0048
run postgres locally via docker
ZibanPirate Oct 2, 2024
6083a79
replaced sqlite with postgres
ZibanPirate Oct 3, 2024
075a2d2
changed primary keys types from integer to text
ZibanPirate Oct 3, 2024
a3c7942
migrate projects endpoint to use postgres
ZibanPirate Oct 3, 2024
ead0d6a
migrate project detail endpoint to use postgres
ZibanPirate Oct 3, 2024
8d27003
migrate project controller to use postgres
ZibanPirate Oct 3, 2024
6b2e746
migrate contributions controller to use postgres
ZibanPirate Oct 3, 2024
b0faae7
migrate contributors controller to use postgres
ZibanPirate Oct 3, 2024
1174979
simplified contributors endpoint
ZibanPirate Oct 3, 2024
c94048b
Refactor unStringifyDeep function to handle errors gracefully
ZibanPirate Oct 4, 2024
59e8183
Refactor EnvRecord class to dynamically generate POSTGRES_URI based o…
ZibanPirate Oct 4, 2024
d871bd2
include Docker installation requirement
ZibanPirate Oct 4, 2024
7561758
add Postgres service in staging and prod instances
ZibanPirate Oct 4, 2024
ad09566
Refactor PostgresService to handle database migration asynchronously
ZibanPirate Oct 4, 2024
67d7964
correct typo in service name in docker-compose.yml
ZibanPirate Oct 4, 2024
48d2e36
wait for Postgres service before starting the application
ZibanPirate Oct 4, 2024
ca7633a
Refactor project ID handling in project pages
ZibanPirate Oct 4, 2024
a448d5d
return project name in /project/:id/name
ZibanPirate Oct 4, 2024
c1e1305
disabled lh-server for now
ZibanPirate Oct 4, 2024
70275a4
remove redundant proxy_pass rules
ZibanPirate Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.reusable.lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,5 @@ jobs:
path: ./web/.lighthouseci
- name: "Get current time"
run: echo "LHCI_BUILD_CONTEXT__COMMIT_TIME=$(date '+%Y-%m-%d %H:%M:%S %z')" >> $GITHUB_ENV
- run: npx lerna run lh:upload --scope "@dzcode.io/web"
# @TODO-ZM: upload to grafana instead of lhci-server
# - run: npx lerna run lh:upload --scope "@dzcode.io/web"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ coverage
# api
api/oracle-cloud/build
api/fetch_cache
api/sqlite_db
api/postgres_db
api/nodemon.json

# web
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Make sure you have:

- [Git](https://git-scm.com/)
- [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))
- [Docker](https://www.docker.com/) installed and running.

### Run it locally

Expand Down
60 changes: 0 additions & 60 deletions api/db/migrations/0000_melodic_shotgun.sql

This file was deleted.

82 changes: 82 additions & 0 deletions api/db/migrations/0000_oval_zemo.sql
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 $$;
Loading
Loading