Skip to content

Commit

Permalink
Some initial jank notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed May 14, 2023
1 parent a7e2cdb commit 43931b3
Show file tree
Hide file tree
Showing 17 changed files with 1,388 additions and 101 deletions.
19 changes: 13 additions & 6 deletions README.md
Expand Up @@ -15,25 +15,32 @@ Bootstrap the environment:

```
docker-compose up -d
npm run setup
pnpm setup
```

Note: If you need to tweak default settings, `cp .env.example .env` and go to town.

Setup the database:

```
make create-db
pnpm db migrate
```

Create a local user to avoid setting up Google credentials:

```
npm run user:create e -w apps/api
pnpm user create [email protected] password -a
```

Run the dev server, which spins up both the `web` and the `api` services:
Load some mock data:

```
npm run dev
pnpm mocks load-all [email protected]
```

NX is used to manage the monorepo, e.g.
Run the dev server, which spins up both the `web` and the `api` services:

```
npx nx run-many -t build
npm run dev
```
26 changes: 26 additions & 0 deletions apps/api/migrations/0005_thin_jasper_sitwell.sql
@@ -0,0 +1,26 @@
ALTER TYPE "object_type" ADD VALUE 'tasting';
ALTER TYPE "object_type" ADD VALUE 'toast';
ALTER TYPE "object_type" ADD VALUE 'follow';
CREATE TABLE IF NOT EXISTS "notifications" (
"id" bigserial PRIMARY KEY NOT NULL,
"user_id" bigint NOT NULL,
"from_user_id" bigint,
"object_id" bigint NOT NULL,
"object_type" object_type NOT NULL,
"created_at" timestamp NOT NULL,
"read" boolean DEFAULT false NOT NULL
);

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

DO $$ BEGIN
ALTER TABLE "notifications" ADD CONSTRAINT "notifications_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 $$;

CREATE UNIQUE INDEX IF NOT EXISTS "notifications_unq" ON "notifications" ("user_id","object_id","object_type","created_at");

0 comments on commit 43931b3

Please sign in to comment.