John Cantrell
05/21/2022, 4:50 PMJohn Cantrell
05/21/2022, 4:51 PMNorbert Takács
05/21/2022, 6:18 PMdatasource db {
provider = "sqlite"
url = "file:./../config/rss_bot_database.db"
}
model rss {
id Int @id @unique(map: "sqlite_autoindex_rss_1") @default(autoincrement())
link String @unique(map: "sqlite_autoindex_rss_2")
last String
name String @unique(map: "sqlite_autoindex_rss_3")
}
trying to move to this schema.
datasource db {
provider = "sqlite"
url = "file:./../config/rss_bot_database.db"
}
model rss {
id Int @id @unique(map: "sqlite_autoindex_rss_1") @default(autoincrement())
link String
last String
name String
chat_id Int @default(0)
}
model setting {
id Int @id @unique @default(autoincrement())
show_changelog Boolean @default(true)
last_version String
chat_id Int @unique
delay Int
}
I get the following error:
npx prisma migrate dev --name multichat
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": SQLite database "rss_bot_database.db" at "file:./../config/rss_bot_database.db"
- The migration `20220503190343_multichat` failed.
- Drift detected: Your database schema is not in sync with your migration history.
The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.
It should be understood as the set of changes to get from the expected schema to the actual schema.
[+] Added tables
- rss
[*] Changed the `rss` table
[+] Added unique index on columns (name)
[+] Added unique index on columns (link)
[+] Added unique index on columns (id)
- The migrations recorded in the database diverge from the local migrations directory.
✔ We need to reset the SQLite database "rss_bot_database.db" at "file:./../config/rss_bot_database.db".
Do you want to continue? All data will be lost.
I am new to prisma, what can I do? It makes no sense 😢chepte
05/21/2022, 6:30 PMAaron Waller
05/21/2022, 6:58 PMconst getActiveUsers = await prisma.user.findMany({
take: 10,
orderBy: {
posts: {
_count: 'desc',
},
},
})
This is not working for me, I only can choose the fields inside “orderBy” that are not arrays.
Am I missing something? Its a simple one-to-many relationBailey Granam
05/21/2022, 7:41 PMwhere
statement. For now I am using a raw query but would rather not if possible.
Current:
SELECT "Resource".*
FROM "Resource"
LEFT JOIN "Appointment" ON "Appointment"."resourceId" = "Resource"."id"
WHERE "Appointment"."id" IS NULL
OR NOT (
"Appointment"."startAt" < ${range.endDate}
AND ("Appointment"."startAt" + INTERVAL '1 Minute' * "Appointment"."duration") > ${range.startDate}
);
Desired:
prisma.resource.findMany({
where: {
appointments: {
none: {
startAt: { lt: range.endDate },
// How do I query:
// ("Appointment"."startAt" + INTERVAL '1 Minute' * "Appointment"."duration") > ${range.startDate}
},
},
},
});
Hoàng Anh Uy Vũ
05/22/2022, 2:38 AMAnkit Singh
05/22/2022, 7:17 AMmodel User {
id Int @id @default(autoincrement())
username String? @unique
Post Post[]
PostLike Post[] @relation("likeTable")
}
model Post {
id Int @id @default(autoincrement())
content String?
userId Int
user User @relation("posts", fields: [userId], references: [id])
Likes User[] @relation("likeTable")
}
Omar
05/22/2022, 8:12 AMVyrek XD
05/22/2022, 3:38 PMimageID String @id @default(auto()) @map("_id") @db.ObjectId
messageID String?
userID String?
guild String?
channelID String?
logID String?
url String
type String
interactionType String?
isVideo Boolean?
tags String[]
likedBy Users[] @relation(fields: [likedByIds], references: [id])
likedByIds String[]
}
model Users {
id String @id @map("_id")
premium Boolean @default(false)
tagsSuggested Int @default(0)
baraRequested Int @default(0)
isContribuitor Boolean @default(false)
liked Images[]
}
Vyrek XD
05/22/2022, 3:38 PMVyrek XD
05/22/2022, 3:38 PMVyrek XD
05/22/2022, 3:38 PMVyrek XD
05/22/2022, 3:38 PMprisma chobo
05/22/2022, 7:40 PMawait prisma.userAgent.aggregateRaw({
pipeline: [
{
$search: {
compound: {
must: [
{
text: {
query: "opera",
path: {
wildcard: "*",
},
},
},
{
equals: {
path: "application_id",
value: 'ObjectId("6284913de2e5beb0e6336033")',
},
},
],
},
},
},
],
});
For the value field, I tried 'ObjectId("6284913de2e5beb0e6336033")', new ObjectID("id"), "6284913de2e5beb0e6336033", etc...
All fails with the same error message.
How do I pass ObjectId to mongodb atlas using aggregateRaw????Berian Chaiwa
05/22/2022, 9:51 PMyarn
but after I run npx prisma init
I am seeing it attempting to install Prisma
again when I have already done that via yarn add
. Any quick pointers?
Need to install the following packages:
prisma
Ok to proceed? (y)
> Downloading Prisma engines for Node-API for debian-openssl-1.1.x
Erik Näslund
05/22/2022, 11:31 PMChris Tsongas
05/23/2022, 1:06 AMAlan
05/23/2022, 3:27 AM(new PrismaClient()).album
but when chaining .findMany()
after that I get an exception The table 'public.Album' does not exist in the current database.
, which doesn't make sense since I have checked on both the remote postgres db and the remote postgres shadow db and both have a public Album table. Any help is much appreciatedAlan
05/23/2022, 3:28 AM(new PrismaClient()).album
also shows {}
shibi
05/23/2022, 8:34 AMtype User {
id: String
stats: Stats
}
type Stats {
id: String
}
I have User in prisma1 and prisma2. And I have stats in prisma2 only.
When I am overriding whole user query to prisma2 it works good with custom resolver to receive stats:
User {
stats: (parent, args, context) => {
return context.newPrisma.user.findUnique({
where: { id: parent.id },
}).stats();
}
}
But when I won't override user query to new prisma and will use old prisma to fetch user, it won't use stats resolver 😞
Is it possible to somehow force graphql/prisma to use prisma2 resolver inside prisma1 query?
This is only simple example, application is complex so I would like to somehow keep it consistent for now and migrate it part by part.
Thanks in advance and have a great Monday!Adrian
05/23/2022, 8:44 AM// prisma.client.ts
export type Post {
decimal: Prisma.Decimal
}
// post.entity.ts
class Post {
decimal: string
}
// post.controller.ts
async function findOnePost(): Promise<Post> {
return prisma.post.findOne()
}
Brothak
05/23/2022, 9:07 AMString
into napi string
. Seems related to https://prisma.slack.com/archives/CA491RJH0/p1651696799848119
The thing is I can’t reproduce it constantly. It happens with same query but only when pass certain string as parameter. Tried on 3.14 and 3.12Kate
05/23/2022, 11:05 AMKavita Nambissan
05/23/2022, 12:11 PMnpx prisma db pull
and npx prisma generate
and now I cannot create any records due to an error The column new does not exist
There was no column new
to begin with. I don't use prisma migrate
the database is modified manually by the team, and it makes sense to update the Prisma schema as per the database. This is only happening with this one table. Any suggestions on what could be wrong? Thank you!Giorgia Mazzini
05/23/2022, 1:55 PMThat's the error I get: :sob:{
"errors": [
{
"message": "\nInvalid `prisma.queryRaw()` invocation:\n\n\n Raw query failed. Code: `42601`. Message: `db error: ERROR: syntax error at or near \"$1\"`",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"getCars"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"code": "P2010",
"clientVersion": "3.13.0",
"meta": {
"code": "42601",
"message": "db error: ERROR: syntax error at or near \"$1\""
},
"stacktrace": [
"Error: ",
"Invalid `prisma.queryRaw()` invocation:",
"",
"",
" Raw query failed. Code: `42601`. Message: `db error: ERROR: syntax error at or near \"$1\"`",
" at Object.request (C:\\Users\\Giorgia.Mazzini\\Documents\\learninggraphql\\smarter01\\BE\\node_modules\\@prisma\\client\\runtime\\index.js:45629:15)",
" at async Proxy._request (C:\\Users\\Giorgia.Mazzini\\Documents\\learninggraphql\\smarter01\\BE\\node_modules\\@prisma\\client\\runtime\\index.js:46456:18)"
]
}
}
}
],
"data": {
"getCars": null
}
}
That's my code
getCars: (_parent, { input }, { prisma }) => {
if(input){
console.log(input) // --> SELECT * FROM car WHERE car."plate" ILIKE '%123%' //type String
const differentInput = '%123%'
// const result = prisma.$queryRaw`SELECT * FROM car WHERE car."plate" ILIKE '%123%'` // works
// const result = prisma.$queryRaw`SELECT * FROM car WHERE car."plate" ILIKE ${differentInput}` // works
// const result = prisma.$queryRawUnsafe(input) // Works
const result = prisma.$queryRaw`${input}` // Doesn`t work!!!!
return result
}
// ... Other code
}
Kelly Copley
05/23/2022, 4:21 PMThe column (not available) does not exist in the current database
Richard Piacentini
05/23/2022, 4:50 PMRichard Piacentini
05/23/2022, 4:54 PMprisma.cities.findFirst({
where: {
name: {
equals: name,
mode: "insensitive",
},
},
});
Jacob Martin
05/23/2022, 5:38 PM» npx prisma migrate dev --name add_config --create-only
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "xxx", schema "public" at "<http://xxx.b.db.ondigitalocean.com:25060|xxx.b.db.ondigitalocean.com:25060>"
Error: P3006
Migration `20220222031047_init` failed to apply cleanly to the shadow database.
Error code: P1014
Error:
The underlying table for model `migrations` does not exist.