-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
5,510 additions
and
22 deletions.
There are no files selected for viewing
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,37 @@ | ||
name: Integration Test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
integration-test: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
with: | ||
version: 9 | ||
run_install: false | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Run integration tests | ||
run: cd integration && pnpm test |
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,14 @@ | ||
import type { Config } from "drizzle-kit"; | ||
|
||
if (!process.env.DATABASE_URL) { | ||
throw new Error("DATABASE_URL is not defined."); | ||
} | ||
|
||
export default { | ||
schema: "./drizzle/schema.ts", | ||
out: "./drizzle", | ||
dialect: "postgresql", | ||
dbCredentials: { | ||
url: "postgresql://user:[email protected]:5632/drizzle_zero", | ||
}, | ||
} satisfies Config; |
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,26 @@ | ||
CREATE DATABASE drizzle_zero; | ||
CREATE DATABASE drizzle_zero_cvr; | ||
CREATE DATABASE drizzle_zero_cdb; | ||
|
||
\c drizzle_zero; | ||
|
||
CREATE TABLE "medium" ( | ||
"id" text PRIMARY KEY NOT NULL, | ||
"name" text NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE "message" ( | ||
"id" text PRIMARY KEY NOT NULL, | ||
"senderId" text, | ||
"mediumId" text, | ||
"body" text NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE "user" ( | ||
"id" text PRIMARY KEY NOT NULL, | ||
"name" text NOT NULL, | ||
"partner" boolean NOT NULL | ||
); | ||
--> statement-breakpoint | ||
ALTER TABLE "message" ADD CONSTRAINT "message_senderId_user_id_fk" FOREIGN KEY ("senderId") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint | ||
ALTER TABLE "message" ADD CONSTRAINT "message_mediumId_medium_id_fk" FOREIGN KEY ("mediumId") REFERENCES "public"."medium"("id") ON DELETE no action ON UPDATE no action; |
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,139 @@ | ||
{ | ||
"id": "aae07e9c-34a6-4917-ae21-19b574e9719c", | ||
"prevId": "00000000-0000-0000-0000-000000000000", | ||
"version": "7", | ||
"dialect": "postgresql", | ||
"tables": { | ||
"public.medium": { | ||
"name": "medium", | ||
"schema": "", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "text", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"name": { | ||
"name": "name", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {}, | ||
"policies": {}, | ||
"checkConstraints": {}, | ||
"isRLSEnabled": false | ||
}, | ||
"public.message": { | ||
"name": "message", | ||
"schema": "", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "text", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"senderId": { | ||
"name": "senderId", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"mediumId": { | ||
"name": "mediumId", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"body": { | ||
"name": "body", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": { | ||
"message_senderId_user_id_fk": { | ||
"name": "message_senderId_user_id_fk", | ||
"tableFrom": "message", | ||
"tableTo": "user", | ||
"columnsFrom": [ | ||
"senderId" | ||
], | ||
"columnsTo": [ | ||
"id" | ||
], | ||
"onDelete": "no action", | ||
"onUpdate": "no action" | ||
}, | ||
"message_mediumId_medium_id_fk": { | ||
"name": "message_mediumId_medium_id_fk", | ||
"tableFrom": "message", | ||
"tableTo": "medium", | ||
"columnsFrom": [ | ||
"mediumId" | ||
], | ||
"columnsTo": [ | ||
"id" | ||
], | ||
"onDelete": "no action", | ||
"onUpdate": "no action" | ||
} | ||
}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {}, | ||
"policies": {}, | ||
"checkConstraints": {}, | ||
"isRLSEnabled": false | ||
}, | ||
"public.user": { | ||
"name": "user", | ||
"schema": "", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "text", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"name": { | ||
"name": "name", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"partner": { | ||
"name": "partner", | ||
"type": "boolean", | ||
"primaryKey": false, | ||
"notNull": true | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {}, | ||
"policies": {}, | ||
"checkConstraints": {}, | ||
"isRLSEnabled": false | ||
} | ||
}, | ||
"enums": {}, | ||
"schemas": {}, | ||
"sequences": {}, | ||
"roles": {}, | ||
"policies": {}, | ||
"views": {}, | ||
"_meta": { | ||
"columns": {}, | ||
"schemas": {}, | ||
"tables": {} | ||
} | ||
} |
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 @@ | ||
{ | ||
"version": "7", | ||
"dialect": "postgresql", | ||
"entries": [ | ||
{ | ||
"idx": 0, | ||
"version": "7", | ||
"when": 1734976514122, | ||
"tag": "0000_spicy_meteorite", | ||
"breakpoints": true | ||
} | ||
] | ||
} |
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,20 @@ | ||
import { pgTable, text } from "drizzle-orm/pg-core"; | ||
import { boolean } from "drizzle-orm/pg-core"; | ||
|
||
export const user = pgTable("user", { | ||
id: text("id").primaryKey(), | ||
name: text("name").notNull(), | ||
partner: boolean("partner").notNull(), | ||
}); | ||
|
||
export const medium = pgTable("medium", { | ||
id: text("id").primaryKey(), | ||
name: text("name").notNull(), | ||
}); | ||
|
||
export const message = pgTable("message", { | ||
id: text("id").primaryKey(), | ||
senderId: text("senderId").references(() => user.id), | ||
mediumId: text("mediumId").references(() => medium.id), | ||
body: text("body").notNull(), | ||
}); |
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,24 @@ | ||
{ | ||
"name": "drizzle-zero-integration", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"build-schema": "zero-build-schema -p schema.ts", | ||
"db:generate": "drizzle-kit generate", | ||
"test": "vitest run", | ||
"postinstall": "pnpm run build-schema" | ||
}, | ||
"dependencies": { | ||
"drizzle-zero": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@testcontainers/postgresql": "^10.16.0", | ||
"@types/pg": "^8.11.10", | ||
"@types/ws": "^8.5.13", | ||
"@vitest/browser": "^2.1.8", | ||
"drizzle-kit": "^0.30.1", | ||
"pg": "^8.13.1", | ||
"testcontainers": "^10.16.0", | ||
"ws": "^8.18.0" | ||
} | ||
} |
Oops, something went wrong.