Marius Popa
09/22/2022, 10:01 AMnpx prisma migrate dev
which created the latest version of the db. Locally I could see the new field in the migration, commited and pushed to github and created a PR for the change. When my colleague checked my PR, everything was alright and it was merged. However, our Dev branch is connected to the test server and the db migration seemed to fail for it, the field is not there. I would appreciate a lot if someone has some time to look over the error I drop in the comments of this thread, maybe you encounter the problem too : ) thank you a lot!Fishie
09/22/2022, 11:15 AMPaul
09/22/2022, 1:20 PMwhere = { path: folderId !== null ? { has: folderId } : undefined }But when I am at the root, I get all the files and folders. When I query in psql:
select id, name, path from dam_file where path is null;Then I only get the data that’s at the root level of the directory. How do I ensure I am duplicating the psql for a Prisma query? Thanks
Kenny Tran
09/22/2022, 3:32 PMZac Wellmer
09/22/2022, 4:25 PM_prisma_migrations
table that has an applied_steps_count=0
? I made a stupid mistake which is causing a rolled back migration to have have the same migration name as an applied migration (but different check sums)Ivan Jeremic
09/22/2022, 4:33 PMEric Simon
09/22/2022, 5:38 PMmodel User {
user_id string
}
I want the table to be:
create table as Users (
userId" VARCHAR(255) NOT NULL
)
Nicolas Rodriguez
09/22/2022, 5:43 PMJeremy Hinegardner
09/22/2022, 6:33 PMŁukasz Usarz
09/22/2022, 6:53 PM$transaction
API and wonder how should I write jest
unit tests that checks if transaction was rollbacked when error occurred:
await this.prisma.$transaction(async (prisma) => {
const user = await prisma.user.create({ data });
await this.mailerService.sendEmail(user);
});
//...
jest
.spyOn(mailerService, 'sendEmail')
.mockImplementation(async (user: User) => {
throw new Error('Email sent error');
});
Kenny Tran
09/22/2022, 8:45 PMSabin Adams
09/22/2022, 11:30 PMHan Han
09/23/2022, 1:06 AMdbgenerated
Postgresql look like that:
CREATE OR REPLACE FUNCTION create_payment_id_code(INTEGER) RETURNS text AS $$
SELECT CASE
WHEN $1 < 10000 THEN 'PM' || to_char($1, 'FM00000')
ELSE concat('TT', $1)
END;
$$ LANGUAGE sql immutable;
ALTER TABLE public.payments
ADD COLUMN "paymentIdCode" TEXT UNIQUE NOT NULL GENERATED ALWAYS AS (create_payment_id_code("paymentId")) STORED;
When I use prisma db pull
paymentIdCode String? @unique @default(dbgenerated("create_payment_id_code(\"paymentId\")"))
when run migrate then get the error: ERROR: cannot use column reference in DEFAULT expression.
David Van Isacker
09/23/2022, 1:48 AMconst data = await this.prisma.$queryRaw(
Prisma.sql`SELECT time_bucket('1 day'::interval, p.time::timestamptz) from prices p limit 10`,
);
I get the following error:
Exception occured : Error in processing the request : \nInvalid `prisma.$queryRaw()` invocation:\n\n\nRaw query failed. Code: `42883`. Message: `db error: ERROR: function time_bucket(interval, timestamp with time zone) does not exist\nHINT: No function matches the given name and argument types. You might need to add explicit type casts.`"}
The same query works perfectly in my SQL editor. I've tried with and without type casts but i doesn't seem to work.
Any ideas ?
Thanks!Harris Rothaermel
09/23/2022, 3:17 AMPeter
09/23/2022, 1:42 PMSELECT * FROM user WHERE name ~* '\mhello';
Unforunately, something like this:
prisma.user.findMany({ where: { name: { contains: `\\mhello`, mode: 'insensitive' } } })
does not workBarnaby
09/23/2022, 3:37 PMBarnaby
09/23/2022, 3:38 PMprisma migrate reset
failsJoey
09/23/2022, 5:10 PMconst res = await prisma.table.findFirst({where: { size: { IN: [1,2,3,4,5] }});
Joey
09/23/2022, 5:12 PMin
🤦♂️ven v
09/23/2022, 5:51 PMven v
09/23/2022, 5:53 PMsaqib Bhatti
09/23/2022, 8:03 PMLewis
09/24/2022, 1:55 AMconst items = [{item: "thing1", amount: 1}, {item: "thing2", amount: 2}, {item: "thing3", amount: 10}];
await prisma.inventory.update({
where: {
id,
},
data: {
ITEM: {
increment: AMOUNT,
}
}
});
Kenny Tran
09/24/2022, 8:37 AMKenny Tran
09/24/2022, 9:48 AMMrDrummer25
09/24/2022, 9:05 PMCanaan Linder
09/24/2022, 11:12 PMJake W
09/25/2022, 12:27 AMmodel Guild {
id String @id @default(auto()) @map("_id") @db.ObjectId
guildId String @unique
modules Modules
users Member[]
}
model Member {
id String @id @default(auto()) @map("_id") @db.ObjectId
rblxId Int @default(0)
xp Int @default(0)
userId String @default("0")
medalIDs String[] @db.ObjectId
medals Medal[] @relation(fields: [medalIDs], references: [id])
guildId String
Guild Guild @relation(fields: [guildId], references: [id])
}
Hasan
09/25/2022, 8:33 AM