- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat: test ts db (#5224)
Showing
11 changed files
with
94 additions
and
6 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
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 @@ | ||
generated |
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
generator client { | ||
provider = "prisma-client-js" | ||
output = "./generated/db.ts" | ||
} | ||
|
||
datasource db { | ||
|
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,19 @@ | ||
import { PrismaClient } from './generated/leafwatch.ts'; | ||
|
||
const leafwatchClientSingleton = () => { | ||
return new PrismaClient(); | ||
}; | ||
|
||
type LeafwatchClientSingleton = ReturnType<typeof leafwatchClientSingleton>; | ||
|
||
const globalForLeafwatch = globalThis as unknown as { | ||
leafwatch: LeafwatchClientSingleton | undefined; | ||
}; | ||
|
||
const leafwatch = globalForLeafwatch.leafwatch ?? leafwatchClientSingleton(); | ||
|
||
export default leafwatch; | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
globalForLeafwatch.leafwatch = leafwatch; | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/db/prisma/leafwatch/migrations/20240810071922_init/migration.sql
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 @@ | ||
-- CreateTable | ||
CREATE TABLE "Event" ( | ||
"id" UUID NOT NULL DEFAULT gen_random_uuid(), | ||
"actor" TEXT, | ||
"fingerprint" TEXT, | ||
"name" TEXT NOT NULL, | ||
"properties" JSONB, | ||
"referrer" TEXT, | ||
"url" TEXT, | ||
"browser" TEXT, | ||
"ip" TEXT, | ||
"city" TEXT, | ||
"country" TEXT, | ||
"created" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "Event_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Impression" ( | ||
"id" UUID NOT NULL DEFAULT gen_random_uuid(), | ||
"publication" TEXT NOT NULL, | ||
"viewed" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "Impression_pkey" PRIMARY KEY ("id") | ||
); |
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,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
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,30 @@ | ||
generator client { | ||
provider = "prisma-client-js" | ||
output = "./generated/leafwatch.ts" | ||
} | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = env("LEAFWATCH_DATABASE_URL") | ||
} | ||
|
||
model Event { | ||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid | ||
actor String? | ||
fingerprint String? | ||
name String | ||
properties Json? | ||
referrer String? | ||
url String? | ||
browser String? | ||
ip String? | ||
city String? | ||
country String? | ||
created DateTime @default(now()) | ||
} | ||
|
||
model Impression { | ||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid | ||
publication String | ||
viewed DateTime @default(now()) | ||
} |
f5961de
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.
Successfully deployed to the following URLs:
web – ./
heyxyz.vercel.app
web-heyxyz.vercel.app
hey.xyz
web-git-main-heyxyz.vercel.app