Brothak
04/19/2022, 5:46 AMBrothak
04/19/2022, 6:28 AMBrothak
04/19/2022, 6:28 AMhenry
04/19/2022, 6:46 AMJonathan Gotti
04/19/2022, 9:05 AMNatalia
user
04/19/2022, 10:01 AMIbtisam Khalid
04/19/2022, 10:07 AMIbtisam Khalid
04/19/2022, 10:08 AMSönke Peters
04/19/2022, 12:04 PMSELECT ... FROM (SELECT ... FROM xxx)
? I need to run a query and do some more stuff (aggregation, sorting) with its results. I would like to do that in the database rather than manually in my app (e.g. with result.sort(...)
or result..reduce(...)
). Is there a way?aj
04/19/2022, 12:12 PMTaha Bilge
04/19/2022, 1:21 PMbinaryTarget = ["native"]
line to the schema.prisma
file manually each time one of us generates the db. Are there any solutions to this that we might not be aware of? Thanks!Muhammad Tahir
04/19/2022, 1:56 PMkyohei
04/19/2022, 2:11 PMdhatGuy
04/19/2022, 4:04 PMmodel User {
id String @id @default(uuid()) /// @zod.uuid({ message: "Invalid UUID" })
name String
email String @unique /// @zod.email({ message: "Invalid email address" })
username String @unique /// @zod.min(3)
phone String? /// @zod.min(10).max(12)
passwordHash String
emailVerified Boolean @default(false)
acceptedTermsOfUse Boolean @default(false)
points Points[]
wish String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Points {
id Int @id @default(autoincrement()) /// @zod.int({ message: "Invalid UUID" })
userId String
User User @relation(fields: [userId], references: [id])
points Int @default(0)
totalAfter Int @default(0)
desc String
action PointsAction
createdAt DateTime @default(now())
}
How do I store the total of points in the user table, please?Yunbo
04/19/2022, 7:54 PMDATABASE_URL
not found when used docker.
in my docker-compose.yml
, i'm passing env_file
directive.
version: "3.3"
services:
myapp:
build:
context: .
dockerfile: ./Dockerfile
env_file:
- .env.dev
this doesn't seem to work.
in docker container, it ran npx prisma migrate deploy
and i'm getting DATBASE_URL is missingJacob Coker-Dukowitz
04/19/2022, 10:11 PMdb/generated/client
when it should search in ./db/generated/client
:
I get a 'module not found' error when prisma tries to find my query engine binary here, which results in the 'Library may be corrupt' error defined below that line. However the engine is there - it looks like the path prisma is using to find the engine is wrong. Oddly this only occurs when working in a Docker image. Code runs fine locally. Here's where it looks:
prisma:client:libraryEngine Searching for Query Engine Library in db/.prisma/client +0ms
prisma:client:libraryEngine Searching for Query Engine Library in /Users/path/to/local/directory/my-service/db/generated/client +1ms
prisma:client:libraryEngine Searching for Query Engine Library in db/generated/client +0ms
When I add ./
in front of the path to resolve the engine as ./db/generated/client
, the code works.
Does the engine need to be located at the root, or is there something obvious I'm doing wrong?Renato Alves
04/19/2022, 11:47 PMChristopher Ehrlich
04/20/2022, 8:55 AMRicardo Seromenho
04/20/2022, 3:10 PMDominik Jašek
04/20/2022, 4:12 PMprisma generate --watch
? I find a bit cumbersome to execute prisma generate
each time I change schema.prisma
file. Or what is the best practise?Yunbo
04/20/2022, 8:41 PMnpx prisma migrate dev --name "init"
3. threw an error saying type "citext" does not exist
4. npx prisma migrate resolve --rolled-back "xxxx-init"
5. it's rolled back
6. modified "xxxx-init" migration sql by adding
CREATE EXTENSION IF NOT EXISTS citext;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
7. npx prisma migrate deploy
8. All migrations have been successfully applied.
9, added on column in one table in schema.prisma
10. npx prisma migrate dev --name "add_type_in_flavor"
11. It says
The migration `xxxx-init` was modified after it was applied.
✔ We need to reset the PostgreSQL database "postgres" at "localhost:5439".
Do you want to continue? All data will be lost.
i feel like i did something wrong on around step 3 when I tried to resolve the failed migration.
How can I resolve this issue without losing data?Casey Chow
04/20/2022, 8:42 PMprisma migrate resolve --applied
Ryan Westlake
04/20/2022, 9:42 PMJson
fields defined in my models. For example:
model Template {
pages Json @default("[]")
}
An example of a page is:
{
title: string; // e.g. 'blah'
}
Because we cannot add specific types to Json
fields for postgres yet, when I start looping through pages
all of the keys throw a typescript error like the image below. It is a Prisma.JsonValue
instead of a string
. This forces me to put the values in a variable and cast them as the correct type whenever I want to reference them. As you can expect, that litters the code base with casts and is certainly not what I want.
Maybe I’m missing something… how are folks dealing with this?Faizan
04/20/2022, 10:02 PMcreateMany
with a nested create, but it is not supported.
Privilege.createMany({ data: { invite: { create: { data } }}});
What alternative do I have? Thanks.engineer1234
04/21/2022, 1:33 AMreferentialIntegrity = "prisma"
2. keep foreign keys by manually references them/setting them up (somehow) in your schema file?Ian Ray
04/21/2022, 2:51 AMcreateMany
not return the created models, and only a count
?Kasir Barati
04/21/2022, 7:24 AMwhere: {
AND: [
{
email: filters.email,
fullname: filters.fullname,
inquiryType: {
in: filters.inquiryTypes,
},
phone: filters.phone,
},
],
},
and
where: {
AND: [
{ email: filters.email },
{ fullname: filters.fullname },
{ inquiryType: { in: filters.inquiryTypes } },
{ phone: filters.phone }
],
},
In Prisma?Kasir Barati
04/21/2022, 9:37 AMmodel City {
id String @id() @unique() @map("city_code_alphabet_3") @db.VarChar(3)
// Relationships
ArticleForDestination Article[] @relation(name: "articleForDestination")
ArticleForOrigin Article[] @relation(name: "articleForOrigin")
@@map("cities")
}
model Article {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(0)
updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamptz(0)
// Relationships
destinationCityId String @map("destination_city_id")
Destination City @relation(name: "articleForDestination", fields: [destinationCityId], references: [id])
originCityId String @map("origin_city_id")
Origin City @relation(name: "articleForOrigin", fields: [originCityId], references: [id])
@@index([destinationCityId, originCityId])
@@map("article")
}
Problem: I can insert multiple record with the same destinationCityId
and originCityId
? What is wrong?Alex Emerich
04/21/2022, 10:00 AM