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/drizzle #6
Merged
Merged
Feat/drizzle #6
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b81751d
Capture edition on checkins
dcramer 7fd45c3
Switch to Drizzle
dcramer e27b7bd
More drizzle work
dcramer 2137564
More cleanup
dcramer 9a6d827
Almost there
dcramer 87ade5d
Even closer
dcramer 49bcd98
Correct instructions
dcramer 3a6be1c
Passing tests
dcramer 523441d
Lazy fix test
dcramer 860def4
Switch to pnpm and fix build issues
dcramer ed2fab7
Some tweaks (docker still not working)
dcramer 5148bbf
Fix old commands
dcramer aa11d78
Update endpoint
dcramer fea715e
Ok maybe it works (unclear on Dockerfile)
dcramer File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
layout node | ||
|
||
# dotenv .env | ||
dotenv .env | ||
# dotenv .env.local | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
name: CI | ||
inputs: | ||
node-version: | ||
required: false | ||
description: Node version for setup-node | ||
default: 18.x | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: nrwl/nx-set-shas@v3 | ||
- run: npm ci | ||
- run: docker-compose up -d | ||
- run: npx nx affected -t test --parallel=3 --configuration=ci | ||
- run: npx nx affected -t build --parallel=3 | ||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
- name: Set node version to ${{ inputs.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
- name: Run docker images | ||
run: docker-compose up -d | ||
- name: Run tests | ||
run: npm run test:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
node_modules/ | ||
.pnp/ | ||
.pnp.js | ||
package-lock.json | ||
|
||
# testing | ||
coverage/ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
PG_CONTAINER=docker exec -t peated-postgres-1 | ||
|
||
reset-db: | ||
$(MAKE) drop-db | ||
$(MAKE) create-db | ||
|
||
drop-db: | ||
$(PG_CONTAINER) dropdb --if-exists -h 127.0.0.1 -p 5432 -U postgres peated | ||
$(PG_CONTAINER) dropdb --if-exists -h 127.0.0.1 -p 5432 -U postgres test_peated | ||
|
||
create-db: | ||
$(PG_CONTAINER) createdb -E utf-8 -h 127.0.0.1 -p 5432 -U postgres peated || exit 0 | ||
$(PG_CONTAINER) createdb -E utf-8 -h 127.0.0.1 -p 5432 -U postgres test_peated || exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
web: npm run dev:web | ||
api: npm run dev:api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
NODE_ENV=test | ||
# DATABASE_URL=postgresql://postgres:postgres@localhost:5432/test_peated | ||
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres | ||
JWT_SECRET=super-secret-test-secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"out": "./migrations", | ||
"schema": "./src/db/schema.ts", | ||
"breakpoints": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
DO $$ BEGIN | ||
CREATE TYPE "category" AS ENUM('blend', 'bourbon', 'rye', 'single_grain', 'single_malt', 'spirit'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
CREATE TYPE "entity_type" AS ENUM('brand', 'distiller'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
CREATE TYPE "identity_provider" AS ENUM('google'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
CREATE TYPE "object_type" AS ENUM('bottle', 'edition', 'entity'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
CREATE TABLE IF NOT EXISTS "bottle" ( | ||
"id" bigserial PRIMARY KEY NOT NULL, | ||
"name" varchar(255) NOT NULL, | ||
"category" category, | ||
"brand_id" bigint NOT NULL, | ||
"stated_age" smallint, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"created_by_id" bigint NOT NULL | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS "bottle_distiller" ( | ||
"bottle_id" bigint NOT NULL, | ||
"distiller_id" bigint NOT NULL | ||
); | ||
--> statement-breakpoint | ||
ALTER TABLE "bottle_distiller" ADD CONSTRAINT "bottle_distiller_bottle_id_distiller_id" PRIMARY KEY("bottle_id","distiller_id"); | ||
|
||
CREATE TABLE IF NOT EXISTS "change" ( | ||
"id" bigserial PRIMARY KEY NOT NULL, | ||
"object_id" bigint NOT NULL, | ||
"object_type" object_type NOT NULL, | ||
"data" text NOT NULL, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"created_by_id" bigint NOT NULL | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS "edition" ( | ||
"id" bigserial PRIMARY KEY NOT NULL, | ||
"name" varchar(255) NOT NULL, | ||
"barrel" smallint, | ||
"bottle_id" bigint NOT NULL, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"created_by_id" bigint NOT NULL | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS "entity" ( | ||
"id" bigserial PRIMARY KEY NOT NULL, | ||
"name" text NOT NULL, | ||
"country" text, | ||
"region" text, | ||
"type" entity_type[] NOT NULL, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"created_by_id" bigint NOT NULL | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS "identity" ( | ||
"id" bigserial PRIMARY KEY NOT NULL, | ||
"provider" identity_provider NOT NULL, | ||
"external_id" text NOT NULL, | ||
"user_id" bigint NOT NULL | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS "tasting" ( | ||
"id" bigserial PRIMARY KEY NOT NULL, | ||
"bottle_id" bigint NOT NULL, | ||
"edition_id" bigint, | ||
"comments" text, | ||
"tags" text[], | ||
"rating" double precision NOT NULL, | ||
"image_url" text, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"created_by_id" bigint NOT NULL | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS "user" ( | ||
"id" bigserial PRIMARY KEY NOT NULL, | ||
"email" text NOT NULL, | ||
"password_hash" varchar(256), | ||
"display_name" text, | ||
"picture_url" text, | ||
"active" boolean DEFAULT true NOT NULL, | ||
"admin" boolean DEFAULT false NOT NULL, | ||
"created_at" timestamp DEFAULT now() NOT NULL | ||
); | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE "bottle" ADD CONSTRAINT "bottle_brand_id_entity_id_fk" FOREIGN KEY ("brand_id") REFERENCES "entity"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE "bottle" ADD CONSTRAINT "bottle_created_by_id_user_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE "bottle_distiller" ADD CONSTRAINT "bottle_distiller_bottle_id_bottle_id_fk" FOREIGN KEY ("bottle_id") REFERENCES "bottle"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE "bottle_distiller" ADD CONSTRAINT "bottle_distiller_distiller_id_entity_id_fk" FOREIGN KEY ("distiller_id") REFERENCES "entity"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE "change" ADD CONSTRAINT "change_created_by_id_user_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE "edition" ADD CONSTRAINT "edition_bottle_id_bottle_id_fk" FOREIGN KEY ("bottle_id") REFERENCES "bottle"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE "edition" ADD CONSTRAINT "edition_created_by_id_user_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE "entity" ADD CONSTRAINT "entity_created_by_id_user_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE "identity" ADD CONSTRAINT "identity_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 "tasting" ADD CONSTRAINT "tasting_bottle_id_bottle_id_fk" FOREIGN KEY ("bottle_id") REFERENCES "bottle"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE "tasting" ADD CONSTRAINT "tasting_edition_id_bottle_id_fk" FOREIGN KEY ("edition_id") REFERENCES "bottle"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
ALTER TABLE "tasting" ADD CONSTRAINT "tasting_created_by_id_user_id_fk" FOREIGN KEY ("created_by_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 "bottle_brand_unq" ON "bottle" ("name","brand_id"); | ||
CREATE UNIQUE INDEX IF NOT EXISTS "edition_unq" ON "edition" ("bottle_id","name","barrel"); | ||
CREATE UNIQUE INDEX IF NOT EXISTS "entity_name_unq" ON "entity" ("name"); | ||
CREATE UNIQUE INDEX IF NOT EXISTS "identity_unq" ON "identity" ("provider","external_id"); | ||
CREATE UNIQUE INDEX IF NOT EXISTS "user_email_unq" ON "user" ("email"); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still cant get .env to work like id expect/desire