Juan Carlos Blanco Delgado
01/09/2022, 11:15 PMDregond
01/10/2022, 5:06 AMMradul Jain
01/10/2022, 8:53 AMericsonluciano
01/10/2022, 10:31 AMnext-auth
have support for user.role
enum? i'm planning to add Admin / User permission based on the doc it not possible with prisma adapterStephen Jensen
01/11/2022, 12:39 AMCould not find the migration file at /app/prisma/migrations/dev/migration.sql. Please delete the directory or restore the migration file.
Is there a programmatic way to handle resolving this error? The command that I’m running to get me to this point is: npx prisma migrate dev -n dev
which connects to a postgres container running in the cluster.
I’m running this at a few sites where some of them have fresh databases so this error won’t happen there, but those with existing databases have this error. A partial solution I came up with is to run npx prisma reset -f
which is not ideal because it resets everything but has the further complication that I'd need to somehow run the migrate command and then based on the status code run this reset command which isn't the best solution.Adrian
01/11/2022, 9:47 AMaThing
, bThing
). But the data comes async over a eventbus. So it can happen, that aThing
trys to reference an ID from bThing
, that is currently not there. How can I describe this in the schema, so that I dont get an `Foreign key constraint failed on the field`error?user
01/11/2022, 10:27 AMVasily Zorin
01/11/2022, 3:39 PMAnand George
01/11/2022, 4:00 PMuser
01/11/2022, 5:36 PMprisma db push
command
- Defining indices on relation scalars (the foreign key fields).
Timestamps:
00:00 Intro
00:41 The three best practices
03:34 Enabling and setting referentialIntegrity
in the Prisma schema
04:59 Creating the PlanetScale database
05:44 Branching in PlanetScale
08:54 Creating a PlanetScale connection string
09:11 Creating the database schema with prisma db push
09:37 Seeding the database with some data
10:04 Updating the Prisma schema and using native types to change the column type from VARCHAR to Text
11:54 Checking the data with Prisma Studio
12:37 Defining indices on relation scalars (the foreign key fields).
15:00 PlanetScale branching workflows
15:45 Promoting the main branch to production on PlanetScale
16:12 Creating a new branch to add more columns to the schema
18:05 Connecting to the add-created-at
branch with the pscale connect command
19:08 Updating the DATABASE_URL env var in the .env file
20:12 Evolving the Prisma schema by adding more fields to the models
21:10 Running prisma db push
to update the database schema of the branch
22:20 Creating a deploy request for the schema on PlanetScale
23:39 Deploying the deploy request
24:33 Recapping the branching workflow with a diagram
25:02 Tips for using Prisma and PlanetScale with Vercel
31:29 SummaryChip Clark
01/11/2022, 11:11 PMconst whereClause = {
AND: [
{
InvoiceTransaction: {
some: {
InvoiceDate: { gt: horizon }
}
}
},
{
...(searchString?
{
VendorName: { contains: searchString },
}
: {}),
}
]
}
The schema
model Vendor {
VendorPKID Int @id @default(autoincrement())
VendorUno Int @unique
VendorNumber Int?
VendorID String? @db.VarChar(10)
VendorName String? @db.VarChar(40)
NameUno Int?
VendorTypeCode String? @db.VarChar(5)
AddressUno Int?
Address1 String? @db.VarChar(60)
Address2 String? @db.VarChar(60)
City String? @db.VarChar(60)
State String? @db.VarChar(5)
PostalCode String? @db.VarChar(50)
Note String? @db.VarChar(Max)
Active Boolean @default(false)
ActiveFromDate DateTime @db.Date
ModifiedDate DateTime @default(now()) @db.DateTime
ModifiedBy String @db.VarChar(30)
InvoiceTransaction InvoiceTransaction[]
}
Setting horizon to: 2020-01-11T000000.000Z or 2015-01-11T000000.000Z makes no difference. Both return the same recordsChris Baucom
01/12/2022, 6:02 AMquery relatedPosts {
posts(where: { title: { contains: "Best Restaurants in New York" } }) {
title
}
}
but that only gets me other posts with that same title, How can I get related posts based on each word of the title? Maybe the 10 most recent “Best restaurants” or “Best New York” or “New York”? How should I be thinking about this?
Any and all help is much appreciated 🙏Viswa
01/12/2022, 8:58 AMut dev
01/12/2022, 10:42 AMAnthony Rodriguez
01/12/2022, 5:58 PMDaniel De La Luz
01/12/2022, 7:11 PMMax T
01/12/2022, 7:56 PMid
)` error when trying to make a new entry like this,
const newTag = await prisma.user.update({
where: { id: id },
data: {
tags: {
create: {
name: tag,
},
},
},
});
I'm unsure what is null, since the id
field is the default, autogenerated field. Maybe it has something to do the with relation or schema, which I can provide upon request.Gift Atte
01/12/2022, 10:17 PMOyewole ABAYOMI S.
01/13/2022, 1:06 AMconst i = await this.prisma.transactions.groupBy({
by: ['status'],
where: {
status: { in: ['APPROVED', 'COMPLETED', 'PENDING'] }
},
_count: {
status: true
}
})
console.log(i) // []
// i need something like
// {approved: 0, pending: 0, completed: 0}
Thank you.Alex Van Der Werff
01/13/2022, 2:18 AMwarn(prisma-client) There are already 10 instances of Prisma Client actively running.
I tried to prisma.$disconnect()
, but
UnhandledPromiseRejectionWarning: Error: Can't reach database server at `localhost`:`3307`
mikkelsl
01/13/2022, 9:29 AMconst now = new Date()
const months = Array(6).fill(null)
const statistics = months.map(async (_, i) => {
const gte = getFirstDayOfMonth(now, i)
const lte = getLastDayOfMonth(now, i)
return ctx.db.event.count({ where: { dateFrom: gte, dateFrom: lte }})
})
const results = await Promise.all(statistics)
Mradul Jain
01/13/2022, 10:16 AMEzequiel Lowi
01/13/2022, 11:19 AMNathaniel Babalola
01/13/2022, 2:30 PMTyler Clendenin
01/13/2022, 4:19 PMprisma db seed
command to be used by the seed script?Chris Baucom
01/13/2022, 4:46 PMnpx prisma generate
which I think does the migration as well. I never notice issues locally on dev db. But when trying to push my changes to the prod db with npx prisma db push
I am not convinced it fully worked as I can only see the new table I create but the columns for that table in other models are not showing up. For context here, I added a Comment
model and added a comments
field to my User
and Post
model. I see Comment
table, but not comments
in User
or Post
. Here is output of npx prisma db push
Environment variables loaded from .env
Environment variables loaded from prisma/.env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "demo-prisma-pool-stg", schema "public" at "<http://demo-prisma-db-stg-do-user-4493521-0.b.db.ondigitalocean.com:25061|demo-prisma-db-stg-do-user-4493521-0.b.db.ondigitalocean.com:25061>"
🚀 Your database is now in sync with your schema. Done in 1.03s
✔ Generated Prisma Client (2.23.0) to ./node_modules/@prisma/client in 106ms
✔ Generated TypeGraphQL integration to ./graphql/generated/type-graphql in 5.32s
Yes, I’m on Prisma 2.23.0. Any help is much appreciated as I try and grasp best practices here when making schema changes and pushing to prod 🙂Nathaniel Babalola
01/13/2022, 6:38 PM@db.Time(x)
What should be passed as x
? I don't understand itMradul Jain
01/14/2022, 7:08 AM