maxweld
09/26/2021, 8:46 AM...\test-proj01> npx prisma db push
...
...
The database is already in sync with the Prisma Schema.
Running Generate ....
Generated Prisma Client (3.1.1) to .\node_modules\@prisma\client in 94ms
Error: EPERM: operation not permitted, unlink 'C:\Users\david\AppData\Roaming\npm-cache\_npx\40924\node_modules\prisma\node_modules\@prisma\engines\query_engine-windows.dll.node'
at Object.unlinkSync (fs.js:1251:3)
at fixWinEPERMSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:219:13)
at rimrafSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:319:28)
at C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:350:5
at Array.forEach (<anonymous>)
at rmkidsSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:349:26)
at rmdirSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:342:7)
at fixWinEPERMSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:217:5)
at rimrafSync (C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:319:28)
at C:\Program Files\nodejs\node_modules\npm\node_modules\rimraf\rimraf.js:350:5
I am using Typescript, Vue 3 and mySQL (package.json) attached.
This is the second time I ran the command, but I got similar results the first time, just it build the DB in mySql first that time.
I have attached the Debug Log. At the end it seems to be saying that it is unable to access a dll
'C:\\Users\\david\\Documents\\My-Computing-Projects\\Vue-Prisma\\test-proj01\\node_modules\\prisma\\query_engine-windows.dll.node'
This file does not seem to exist.
Does anybody have any thoughts on what is going on here?
Thanks in advanceJosef Henryson
09/27/2021, 4:02 PMJohn Peña
09/27/2021, 7:47 PMJohn Peña
09/27/2021, 7:48 PMNick Foden
09/29/2021, 2:40 AMprisma migrate dev
errored, but seems it is somewhat applied and now I have a drift scenario and a schema annotated with these new foreign keys etc. Is there command to rollback last migration on database? Been reading the docs and searching around. I can't lose this database. Worst case - thought is to export with mysql workbench or such and then take the platform offline and baseline / seed it with the backup maybe. But that is rough is will be a lot of time.Mischa
10/02/2021, 7:15 AMbinaryTargets = ["native", "rhel-openssl-1.0.x"]
set which seems to fetch me these engines. I am wondering how I get the migration engine for RHEL because I need it for packaging my lambdasJosef Henryson
10/06/2021, 7:23 AMMaciek K
10/07/2021, 11:35 AMnpx prisma migrate dev
on my development branch and db. When doing the npx prisma migrate deploy
against staging environemtn it errored out on this part
Database error:
ERROR: relation "User.email_unique" does not exist
So exactly on this sql statement:
-- RenameIndex
ALTER INDEX "User.email_unique" RENAME TO "User_email_key";
From schema.prisma:
model User {
//deleted unnecessary stuff
email String @unique
}
So only then I did notice the text at the bottom (Dealing with cases where more than one database environment is used for the same application). 🤕
So I have pulled schemas from other database environments and I have a problem, because they do differ indeed. In example on production the index does not have the name User.email_unique
, but:
model User {
email String @unique(map: "booking-production$prod.User.email._UNIQUE")
}
It has also the postgres schema name prepended (!).
So what should I do now? I would also very much like to use the default Prisma 3 naming convention for all environments (User_email_key
)?Sam
10/10/2021, 9:02 PMKATT
10/11/2021, 9:49 AMmigrate dev
works where it prompts you but I just want to make sure no schema changes are checked in without the migration filesJosef Henryson
10/11/2021, 1:50 PMTyler Bell
10/15/2021, 9:25 PMprisma migrate deploy
but that too resulted in errors such as this one…
DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42704"), message: "constraint \"CustomField_memberId_fkey\" of relation \"CustomField\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("tablecmds.c"), line: Some(10987), routine: Some("ATExecDropConstraint") }
We tried manually fixing the errors one by one, but we didn’t get any where with it. No matter what we did, migrate deploy
would never succeed.
That led us to try to start from a clean slate. We tried the following….
1. we first duplicated our production database for testing purposes.
2. we deleted the _prisma_migrations
table
3. we deleted the migrations
folder
4. we then followed the instructions here on adding prisma to an existing project.
a. ran prisma pull db
b. ran prisma migrate dev --name initial-migration --create-only
which resulted in yet another Drift detected: Your database schema is not in sync with your migration history.
message.
At this point we are kinda at a loss 😅
Does anyone know a good approach to take here?Maciek K
10/19/2021, 12:48 PMmodel Booking {
id String @id @default(cuid()) @db.VarChar(30)
name String
forename String?
email String?
phone String?
}
to:
model Booking {
id String @id @default(cuid()) @db.VarChar(30)
clientId String
client Client @relation(fields: [clientId], references: [id])
}
model Client {
id String @id @default(cuid()) @db.VarChar(30)
name String
forename String?
email String?
phone String?
bookings Booking[]
}
I'm asking for the best way to approach this mostly in terms of the whole process and modifying the staging, production databases afterwards.
Are there some script examples using prisma to modify the whole database? Couldn't find anything on the Prisma page except the seed scripts.
Is there anything else I should consider by doing such normalisation. Any pitfalls I should be aware of? Thank You :)Korzun
10/22/2021, 9:44 PMDan Borstelmann
10/31/2021, 6:20 PM./node_modules/prisma/build/index.js migrate deploy --schema=<schema_path>
I've got it mostly working, however the migration-engine binary doesn't exist in the /prisma directory, only /@prisma/engines. Can anyone help me understand the differences between the binary locations which are in /prisma, /@prisma/engines, and /.prisma and what the best way is to point that script to the migration engine which it can't currently find?
Also I can't find a migration-engine-rhel-openssl-1.0.x anywhere, only darwinDan Borstelmann
10/31/2021, 7:30 PMDan Borstelmann
10/31/2021, 7:30 PMDan Borstelmann
10/31/2021, 7:31 PMSKhan
11/10/2021, 9:54 AMrolled-back
command and then then the migrate dev
/ migrate reset
again, to no success
The errors I am getting are:
• for `migrate reset`:
Error: P3018
A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: <https://pris.ly/d/migrate-resolve>
Migration name: 20210722071621_updated_enum_activity_type_to_include_invite_and_message
Database error code: 25001
Database error:
ERROR: ALTER TYPE ... ADD cannot be executed from a function or multi-command string
DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("25001"), message: "ALTER TYPE ... ADD cannot be executed from a function or multi-command string", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("xact.c"), line: Some(3237), routine: Some("PreventTransactionChain") }
• for rolled back
and then `migrate dev`:
Error: P3006
Migration `20210722071621_updated_enum_activity_type_to_include_invite_and_message` failed to apply cleanly to the shadow database.
Error:
db error: ERROR: ALTER TYPE ... ADD cannot be executed from a function or multi-command string
0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:373
1: sql_migration_connector::validate_migrations
at migration-engine/connectors/sql-migration-connector/src/lib.rs:317
2: migration_core::api::DevDiagnostic
at migration-engine/core/src/api.rs:89
How to resolve this?Mischa
11/11/2021, 5:16 PMAdam
11/16/2021, 6:12 PMlogs
column of _prisma_migrations
is empty. Is there someplace I can see the error?Pierre Ortega
11/18/2021, 7:41 PMChris Bitoy
11/24/2021, 5:57 PMFrederik
12/03/2021, 1:39 PMChris Bitoy
12/06/2021, 5:35 PM→ 42 const creatives = await prisma.creative.create({
data: {
brandLogo: 'www.test2.png',
brandName: 'This is a Unique one',
projectName: 'ProjectName is also unique',
headerImage: 'www.imageheader.png',
projectCreative: [
'<http://anothertest2.com|anothertest2.com>',
'<http://anothertest3.com|anothertest3.com>',
'<http://anothertest4.com|anothertest4.com>',
'<http://anothertest5.com|anothertest5.com>'
]
~~~~~~~~~~~~~~~~~~~~~
}
})
Argument projectCreative: Got invalid value
[
'<http://anothertest2.com|anothertest2.com>',
'<http://anothertest3.com|anothertest3.com>',
'<http://anothertest4.com|anothertest4.com>',
'<http://anothertest5.com|anothertest5.com>'
]
on prisma.createOneCreative. Provided List<String>, expected ProjectCreativeCreateNestedManyWithoutCreativeInput:
type ProjectCreativeCreateNestedManyWithoutCreativeInput {
create?: ProjectCreativeCreateWithoutCreativeInput | List<ProjectCreativeCreateWithoutCreativeInput> | ProjectCreativeUncheckedCreateWithoutCreativeInput | List<ProjectCreativeUncheckedCreateWithoutCreativeInput>
connectOrCreate?: ProjectCreativeCreateOrConnectWithoutCreativeInput | List<ProjectCreativeCreateOrConnectWithoutCreativeInput>
createMany?: ProjectCreativeCreateManyCreativeInputEnvelope
connect?: ProjectCreativeWhereUniqueInput | List<ProjectCreativeWhereUniqueInput>
}
But I defined my models to accept an array of strings:
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[]
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
}
via 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": [
"<http://anothertest2.com|anothertest2.com>",
"<http://anothertest3.com|anothertest3.com>",
"<http://anothertest4.com|anothertest4.com>",
"<http://anothertest5.com|anothertest5.com>"
]
}
Can you help me figure it out?Luis Alfredo Lorenzo
12/06/2021, 8:00 PMDatabase error code: 25001
Database error:
ERROR: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
Barnaby
12/07/2021, 12:36 PMBarnaby
12/07/2021, 12:38 PMMigration `20211207122745_genesis` failed to apply cleanly to the shadow database.
db error: ERROR: function uuid_generate_v4() does not exist
And:
postgres=# select uuid_generate_v4();
uuid_generate_v4
--------------------------------------
1c68bfd5-f682-498c-a9b9-59b79ddcfa26
(1 row)
what is meant by "shadow database", is this not my maintenance database? Does the uuid function actually need to be "installed" in each individual database?Barnaby
12/07/2021, 12:41 PMBarnaby
12/07/2021, 12:41 PM