Daniel
12/05/2021, 3:34 AMJohn Meyers
12/05/2021, 7:58 AMawait prisma.$transaction([
prisma.item.create({...})
prisma.item.create({...})
throw new Error('')
])
It's either that awaits are breaking it, or prisma only breaks the transaction on its own internal database errors, so in that case you wouldn't be able to artificially break it yourselfJohn Meyers
12/05/2021, 7:59 AMBenny
12/05/2021, 10:18 AMBenny
12/05/2021, 10:18 AMIddan Aaronsohn
12/05/2021, 12:24 PMEden Lane
12/05/2021, 3:59 PMPaul
12/05/2021, 4:42 PMError: Cannot load from mysql.proc. The table is probably corrupted
0: migration_core::api::SchemaPush
at migration-engine/core/src/api.rs:184
A migration:
Error: Cannot load from mysql.proc. The table is probably corrupted
0: sql_migration_connector::flavour::mysql::sql_schema_from_migration_history
at migration-engine/connectors/sql-migration-connector/src/flavour/mysql.rs:424
1: migration_core::api::DevDiagnostic
at migration-engine/core/src/api.rs:108
Ridhwaan Shakeel
12/05/2021, 6:13 PMDevi Prasad
12/06/2021, 1:58 AMType: PrismaClientKnownRequestError
Message:
Invalid `prisma.traxRecord.create()` invocation:
Null constraint violation on the fields: (`id`)
Code: P2011
Query:
prisma.traxRecord.create(
{
data: {
back_length: null,
back_fat: 0,
frame_score: 0,
loin_eye_area: 0,
loin_eye_depth: 0,
level_1_committed: false,
level_2_committed: false,
measured_on: "1970-01-01T00:00:00.000Z",
birth_weight: 0,
weaning_weight: 0,
six_month_weight: 0,
yearling_weight: 0,
date_updated: "2021-12-06T01:55:52.424Z",
type: "SIX_MONTH",
ipi_definition_id: "",
goat: {
connect: {
id: "c7d04d4d-93e9-43e4-8387-04fb83a3bac8",
},
},
user: {
connect: {
id: "9ff02887-f755-49f9-bab2-f8051f66c1b2",
},
},
},
select: {
id: true,
back_length: true,
back_fat: true,
frame_score: true,
loin_eye_area: true,
loin_eye_depth: true,
level_1_committed: true,
level_2_committed: true,
measured_on: true,
goat_id: true,
birth_weight: true,
weaning_weight: true,
six_month_weight: true,
yearling_weight: true,
user_id: true,
date_created: true,
date_updated: true,
type: true,
ipi_definition_id: true,
goat: true,
user: true,
six_month_trax_goat: true,
yearling_trax_goat: true,
},
}
)
This is my schema, this error is also thrown when using the Prisma Client,
model TraxRecord {
id String @id @default(uuid())
back_length Int? @db.UnsignedInt
back_fat Int @db.UnsignedInt
frame_score Int @db.UnsignedInt
loin_eye_area Int @db.UnsignedInt
loin_eye_depth Int @db.UnsignedInt
level_1_committed Boolean
level_2_committed Boolean
measured_on DateTime @db.Date
goat_id String
birth_weight Int @db.UnsignedInt
weaning_weight Int @db.UnsignedInt
six_month_weight Int @db.UnsignedInt
yearling_weight Int @db.UnsignedInt
user_id String
date_created DateTime @default(now())
date_updated DateTime @updatedAt
type TraxRecordType
ipi_definition_id String
// ### Relations ### //
goat Goat @relation(fields: [goat_id], references: [id], onUpdate: Restrict)
user User @relation(fields: [user_id], references: [id], onUpdate: Restrict)
six_month_trax_goat Goat? @relation("six_month_trax", fields: [id], references: [six_month_trax_id], onUpdate: Restrict, map: "six_month_trax_id_t_gt")
yearling_trax_goat Goat? @relation("yearling_trax", fields: [id], references: [yearling_trax_id], onUpdate: Restrict, map: "yearling_trax_id_t_gt")
@@index([goat_id], map: "goat_id")
@@index([user_id], map: "user_id")
@@map("trax_records")
}
model Goat {
id String @id @default(uuid())
animal_id String? @db.VarChar(50)
name String @db.VarChar(50)
registration_id String? @db.VarChar(50)
tattoo_le String? @db.VarChar(50)
tattoo_re String? @db.VarChar(50)
date_of_birth DateTime? @db.Date
sex_label GoatSexLabel
birth_code Int @default(1) @db.UnsignedInt
breed String? @db.VarChar(50)
sire String? @db.VarChar(50)
sire_registration_id String? @db.VarChar(50)
dam String? @db.VarChar(50)
dam_registration_id String? @db.VarChar(50)
six_month_trax_id String?
yearling_trax_id String?
user_id String
date_created DateTime @default(now())
date_updated DateTime @updatedAt
// ### Relations ### //
user User @relation(fields: [user_id], references: [id], onUpdate: Restrict)
traxes TraxRecord[]
six_month_trax TraxRecord? @relation("six_month_trax")
yearling_trax TraxRecord? @relation("yearling_trax")
@@index([six_month_trax_id], map: "six_month_trax_id")
@@index([user_id], map: "user_id")
@@index([yearling_trax_id], map: "yearling_trax_id")
@@map("goats")
}
Ramu Narasinga
12/06/2021, 5:57 AM"strictNullChecks": true
 to our tsconfig.json
.
Node Version: 14
"jest-mock-extended": "^2.0.4",
For now, we are doing // @ts-ignore to avoid this circular dependancy run-time error.
Can any one help how to solve this issue without using ts-ignore?ÎÎčÏÏÎłÎżÏ ÎÏαÏÏÏÏÎżÏ Î»ÎżÏ
12/06/2021, 11:44 AMprisma
client object, and import them every time I want to use them?Phil Bookst
12/06/2021, 2:06 PMbeeloon
12/06/2021, 2:48 PMDaniell
12/06/2021, 3:41 PMimport { config } from "./config"
which causes CustomError: Cannot find module '/workspace/prisma/config' imported from /workspace/prisma/seed.ts
with the following script:
"seed": "node --experimental-specifier-resolution=node --loader ts-node/esm ./prisma/seed.ts"
Kent C. Dodds
12/06/2021, 4:51 PM.prisma/client
in my node_modules
. Should I be importing types from that instead of @prisma/client
now?
It appears that the correct thing to do is import generated types from .prisma/client
and import everything else I need (like PrismaClient
) from @prisma/client
. Is this correct?Noel Martin Llevares
12/06/2021, 5:14 PMWARNING The following migrations have been modified since they were applied:_20210313140442_favorite_colors_
user
12/06/2021, 5:54 PMChris Bitoy
12/06/2021, 8:00 PMconst creatives = await prisma.creative.create({
data: {
brandLogo: 'www.test3.png',
brandName: 'This another one',
projectName: 'ProjectName is unique',
headerImage: 'www.imageheader4.png',
projectCreative: {
cloudinary_url0: '<http://anothertest32.com|anothertest32.com>',
~~~~~~~~~~~~~~~
cloudinary_url1: '<http://anothertest33.com|anothertest33.com>',
~~~~~~~~~~~~~~~
cloudinary_url2: '<http://anothertest44.com|anothertest44.com>',
~~~~~~~~~~~~~~~
cloudinary_url3: '<http://anothertest59.com|anothertest59.com>'
~~~~~~~~~~~~~~~
}
}
})
Unknown arg `cloudinary_url0` in data.projectCreative.cloudinary_url0 for type ProjectCreativeCreateNestedManyWithoutCreativeInput. Did you mean `createMany`? Available args:
type ProjectCreativeCreateNestedManyWithoutCreativeInput {
create?: ProjectCreativeCreateWithoutCreativeInput | List<ProjectCreativeCreateWithoutCreativeInput> | ProjectCreativeUncheckedCreateWithoutCreativeInput | List<ProjectCreativeUncheckedCreateWithoutCreativeInput>
connectOrCreate?: ProjectCreativeCreateOrConnectWithoutCreativeInput | List<ProjectCreativeCreateOrConnectWithoutCreativeInput>
createMany?: ProjectCreativeCreateManyCreativeInputEnvelope
connect?: ProjectCreativeWhereUniqueInput | List<ProjectCreativeWhereUniqueInput>
}
Unknown arg `cloudinary_url1` in data.projectCreative.cloudinary_url1 for type ProjectCreativeCreateNestedManyWithoutCreativeInput. Did you mean `createMany`? Available args:
type ProjectCreativeCreateNestedManyWithoutCreativeInput {
create?: ProjectCreativeCreateWithoutCreativeInput | List<ProjectCreativeCreateWithoutCreativeInput> | ProjectCreativeUncheckedCreateWithoutCreativeInput | List<ProjectCreativeUncheckedCreateWithoutCreativeInput>
connectOrCreate?: ProjectCreativeCreateOrConnectWithoutCreativeInput | List<ProjectCreativeCreateOrConnectWithoutCreativeInput>
createMany?: ProjectCreativeCreateManyCreativeInputEnvelope
connect?: ProjectCreativeWhereUniqueInput | List<ProjectCreativeWhereUniqueInput>
}
Unknown arg `cloudinary_url2` in data.projectCreative.cloudinary_url2 for type ProjectCreativeCreateNestedManyWithoutCreativeInput. Did you mean `createMany`? Available args:
type ProjectCreativeCreateNestedManyWithoutCreativeInput {
create?: ProjectCreativeCreateWithoutCreativeInput | List<ProjectCreativeCreateWithoutCreativeInput> | ProjectCreativeUncheckedCreateWithoutCreativeInput | List<ProjectCreativeUncheckedCreateWithoutCreativeInput>
connectOrCreate?: ProjectCreativeCreateOrConnectWithoutCreativeInput | List<ProjectCreativeCreateOrConnectWithoutCreativeInput>
createMany?: ProjectCreativeCreateManyCreativeInputEnvelope
connect?: ProjectCreativeWhereUniqueInput | List<ProjectCreativeWhereUniqueInput>
}
Unknown arg `cloudinary_url3` in data.projectCreative.cloudinary_url3 for type ProjectCreativeCreateNestedManyWithoutCreativeInput. Did you mean `createMany`? Available args:
type ProjectCreativeCreateNestedManyWithoutCreativeInput {
create?: ProjectCreativeCreateWithoutCreativeInput | List<ProjectCreativeCreateWithoutCreativeInput> | ProjectCreativeUncheckedCreateWithoutCreativeInput | List<ProjectCreativeUncheckedCreateWithoutCreativeInput>
connectOrCreate?: ProjectCreativeCreateOrConnectWithoutCreativeInput | List<ProjectCreativeCreateOrConnectWithoutCreativeInput>
createMany?: ProjectCreativeCreateManyCreativeInputEnvelope
connect?: ProjectCreativeWhereUniqueInput | List<ProjectCreativeWhereUniqueInput>
}
I defined my models to accept an array of strings as show below:
model Creative {
id Int @id @default(autoincrement())
owner_id String @default(cuid())
campaign_id String @default(cuid())
parent_c_id String @default(cuid())
brandLogo String
brandName String @unique
projectName String @unique
headerImage String
projectCreative ProjectCreative[] //should accept array of strings
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model ProjectCreative {
id Int @id @default(autoincrement())
creative Creative? @relation(fields: [creativeId], references: [id])
creativeId Int?
cloudinary_url0 String
cloudinary_url1 String
cloudinary_url2 String
cloudinary_url3 String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
And in my POST route:
<http://router.post|router.post>("/creatives", async (req, res) => {
try {
const { brandLogo, brandName, projectName, headerImage, projectCreative } =
req.body;
const creatives = await prisma.creative.create({
data: { brandLogo, brandName, projectName, headerImage, projectCreative },
});
res.status(201).json({ success: true, data: creatives, error: "" });
} catch (error) {
console.log(error);
res.status(500).json({ data: {}, error: error, status: 500 });
}
});
With this test data:
{
"brandLogo": "www.test2.png",
"brandName": "This is a Unique one",
"projectName": "ProjectName is also unique",
"headerImage": "www.imageheader.png",
"projectCreative": {
"cloudinary_url0": "<http://anothertest32.com|anothertest32.com>",
"cloudinary_url1": "<http://anothertest33.com|anothertest33.com>",
"cloudinary_url2": "<http://anothertest44.com|anothertest44.com>",
"cloudinary_url3": "<http://anothertest59.com|anothertest59.com>"
}
Can you help me figure it out?Eden Lane
12/06/2021, 9:36 PMCREATE ROLE grafana WITH PASSWORD 'password';
but Prisma falls with the error:
ERROR: role "grafana" already exists
I've deleted the role, I've reseted DB but the error is still here. Does anybody know what might be the case?Daniel Baumert
12/06/2021, 10:40 PMJinho Chung
12/07/2021, 12:13 AMnpx prisma migrate resolve --applied baseline-migration
) prior to performing npx prisma migrate deploy
every single time? And if multiple resolves need to be performed, do you just execute them on the CLI or script in succession chronologically until you get to migrate deploy
?Mike Willbanks
12/07/2021, 2:18 AMStefano Giraldi
12/07/2021, 9:02 AMUser
and Role
schemas.
In my seed.ts
I have this code
const superadminRole = await prisma.role.upsert({
where: { name: 'superadmin' },
update: {},
create: {
name: 'superadmin',
},
})
const superadmin = await prisma.user.upsert({
where: { email: '<mailto:superadmin@test.com|superadmin@test.com>' },
update: {},
create: {
email: '<mailto:superadmin@test.com|superadmin@test.com>',
name: 'Super Admin',
password: hash,
roles: {
connect: [{name: superadminRole.name}] <--- ts2322 error
}
},
})
I get this typescript error (even if the script works right).
Type '{ name: string; }' is not assignable to type 'UserRoleWhereUniqueInput'.
Object literal may only specify known properties, and 'name' does not exist in type 'UserRoleWhereUniqueInput'.ts(2322)
Can someone help me to understand what is the problem? Thank youMasayuki Yamaguchi
12/07/2021, 9:09 AMawait prisma.$transaction(async (prisma) => {
const txid1 = await prisma.$queryRawUnsafe('SELECT txid_current()')
console.log('txid1', txid1)
const txid2 = await prisma.$queryRawUnsafe('SELECT txid_current()')
console.log('txid2', txid2)
})
But the following case, both txid1 and txid2 have different value(It means different transaction).
await prisma.$transaction(async (prisma) => {
const txid1 = await prisma.$queryRawUnsafe('SELECT txid_current()')
console.log('txid1', txid1)
const txid2 = await prisma.$queryRawUnsafe('SELECT txid_current()').then() // Code changes
console.log('txid2', txid2)
})
I donât know why the behavior changes.
Is this a specification?
Is there any way to use âthen()â in same transaction?
Thank you.Daniell
12/07/2021, 9:13 AMimport { config } from "./config"
which causes CustomError: Cannot find module '/workspace/prisma/config' imported from /workspace/prisma/seed.ts
with the following script:
"seed": "node --experimental-specifier-resolution=node --loader ts-node/esm ./prisma/seed.ts"
Iradukunda Irenee
12/07/2021, 9:45 AMIradukunda Irenee
12/07/2021, 9:46 AM