Skip to content

Commit

Permalink
Add follower graph implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed May 12, 2023
1 parent 2102bdf commit df3ee88
Show file tree
Hide file tree
Showing 54 changed files with 2,107 additions and 136 deletions.
1 change: 0 additions & 1 deletion .eslintcache

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -16,6 +16,7 @@ dev-dist/

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand All @@ -27,6 +28,6 @@ yarn-error.log*

.nyc-output/
.turbo/
.eslintcache

/.env
/postgres-data
1 change: 1 addition & 0 deletions .prettierignore
Expand Up @@ -2,3 +2,4 @@ dev-dist/
dist/
pnpm-lock.yaml
pnpm-workspace.yaml
migrations/
12 changes: 10 additions & 2 deletions Makefile
Expand Up @@ -4,10 +4,18 @@ reset-db:
$(MAKE) drop-db
$(MAKE) create-db

drop-db:
drop-db: drop-db-dev drop-db-test

drop-db-dev:
$(PG_CONTAINER) dropdb --if-exists -h 127.0.0.1 -p 5432 -U postgres peated

drop-db-test:
$(PG_CONTAINER) dropdb --if-exists -h 127.0.0.1 -p 5432 -U postgres test_peated

create-db:
create-db: create-db-dev create-db-test

create-db-dev:
$(PG_CONTAINER) createdb -E utf-8 -h 127.0.0.1 -p 5432 -U postgres peated || exit 0

create-db-test:
$(PG_CONTAINER) createdb -E utf-8 -h 127.0.0.1 -p 5432 -U postgres test_peated || exit 0
26 changes: 26 additions & 0 deletions apps/api/migrations/0003_military_preak.sql
@@ -0,0 +1,26 @@
DO $$ BEGIN
CREATE TYPE "follow_status" AS ENUM('none', 'pending', 'following');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

CREATE TABLE IF NOT EXISTS "follow" (
"from_user_id" bigint NOT NULL,
"to_user_id" bigint NOT NULL,
"status" follow_status DEFAULT 'pending' NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "follow" ADD CONSTRAINT "follow_from_user_id_to_user_id" PRIMARY KEY("from_user_id","to_user_id");

DO $$ BEGIN
ALTER TABLE "follow" ADD CONSTRAINT "follow_from_user_id_user_id_fk" FOREIGN KEY ("from_user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

DO $$ BEGIN
ALTER TABLE "follow" ADD CONSTRAINT "follow_to_user_id_user_id_fk" FOREIGN KEY ("to_user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

0 comments on commit df3ee88

Please sign in to comment.