Skip to content

Commit

Permalink
Merge pull request #609 from dzcode-io/switch-to-postgres
Browse files Browse the repository at this point in the history
feat: Switch to postgres
  • Loading branch information
ZibanPirate authored Oct 5, 2024
2 parents 869676a + 70275a4 commit edb5e3a
Show file tree
Hide file tree
Showing 44 changed files with 691 additions and 648 deletions.
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

0 comments on commit edb5e3a

Please sign in to comment.