Pranav Sathyanarayanan
06/15/2021, 4:14 PMThe migration `20210611143319_denormalized_current_employer` was modified after it was applied.
While running prisma migrate dev --create-only --name=...
, the CLI is saying it has to drop all data and re-add. I haven't modified this script at all, is there a way to override this?Casey Chow
06/15/2021, 9:48 PMAlbert Gao
06/17/2021, 12:56 AMurl
is the online database, and shadowDatabaseUrl
is the local url.
But still, when I run command like migrate reset
, it still uses the url
rather than shadowDatabaseUrl
What am I missing here?Albert Gao
06/17/2021, 12:56 AM.env
file…?Peter Kim
06/17/2021, 12:12 PM@relation
without creating foreign key constraints in the database(mysql)?
When I do prisma db push
, the foreign key constraint is not created, but prisma migrate dev
tries to create it.
In typeorm
@ManyToOne(type => Person, {
createForeignKeyConstraints: false
})
I’m looking for an option similar to this.sven
06/24/2021, 1:07 PMJohn Peña
06/24/2021, 2:22 PMMikastark
07/02/2021, 9:12 AMgenerator client {
provider = "prisma-client-js"
previewFeatures = ["referentialActions"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model Link {
id String @id @default(uuid())
href String
content String
androidLinkSite Site? @relation("androidLinkToSite")
iOSLinkSite Site? @relation("iOSLinkToSite")
}
model Site {
id String @id @default(uuid())
iOSLink Link? @relation("iOSLinkToSite", fields: [iOSLinkId], references: [id])
iOSLinkId String?
androidLink Link? @relation("androidLinkToSite", fields: [androidLinkId], references: [id])
androidLinkId String?
}
I have sites
that have different sorts of links
. In this case an androidLink
and an iOSLink
(both are 1-to-1 relationship). What I want to do is when a site
is deleted, it should delete also it androidLink
and iOSLink
. How can I archieve this ?
One solution can be moving foreign keys from Site to Link and using cascade delete on Link . But it's seems ugly to me as it will polluate my Link table with many potentially unnecessary columnsNimish Gupta
07/06/2021, 6:16 PMenum Position {
First
Second
Last
}
model Test {
id String @id @default(uuid())
name String @unique
positions Position[]
// common fields
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
@@map("test")
}
Now I am removing one value (Last) from enum Position
. So after removing I ran this command:
prisma generate --schema=./schema.prisma && prisma migrate dev --schema=./schema.prisma
Above command created a new migration file like this
/*
Warnings:
- The values [Last] on the enum `Position` will be removed. If these variants are still used in the database, this will fail.
*/
-- AlterEnum
BEGIN;
CREATE TYPE "Position_new" AS ENUM ('First', 'Second');
ALTER TABLE "test" ALTER COLUMN "positions" TYPE "Position_new" USING ("positions"::text::"Position_new");
ALTER TYPE "Position" RENAME TO "Position_old";
ALTER TYPE "Position_new" RENAME TO "Position";
DROP TYPE "Position_old";
COMMIT;
Now if I rerun prisma migrate dev --schema=./schema.prisma
, it should not do any change, because I haven't changed any thing and all the migrations should be completed with above migration file. But it is again asking for a new migration name and when I entered some name for migration it errors by this. Also it created one more migration file
/*
Warnings:
- Changed the column `positions` on the `test` table from a scalar field to a list field. If there are non-null values in that column, this step will fail.
*/
-- AlterTable
ALTER TABLE "test" ALTER COLUMN "positions" SET DATA TYPE "Position"[];
Here I couldn't understand why it is again asking for a new migration and even though we are giving it name it is throwing error.
Prisma version - 2.26.0Kevin Huang
07/07/2021, 2:54 PM10:22:13.228 Error: P3009
10:22:13.228 migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: <https://pris.ly/d/migrate-resolve>
10:22:13.228 The `20210702212552_add_unique_constraint_to_job` migration started at 2021-07-07 13:52:17.927259 UTC failed with the following logs:
10:22:13.245 error Command failed with exit code 1.
And this is the migrate from the error above:
/*
Warnings:
- A unique constraint covering the columns `[queueId]` on the table `Job` will be added. If there are existing duplicate values, this will fail.
- Made the column `vendorResponded` on table `Job` required. This step will fail if there are existing NULL values in that column.
- Made the column `status` on table `Job` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "Job" ALTER COLUMN "vendorResponded" SET NOT NULL,
ALTER COLUMN "status" SET NOT NULL;
-- CreateIndex
CREATE UNIQUE INDEX "Job.queueId_unique" ON "Job"("queueId");
I'm assuming the issue is coming from added REQUIRED
constraint to vendorRespond
and status
columns.
I'm trying to following along this guide here to resolve the issue, I'm a bit confused on how to approach it.
Where are you supposed to run this command in the guide?
From your local machine or you need to ssh into the production machine to do so? Many thanks!
prisma migrate resolve --rolled-back "20201127134938_added_bio_index"
Adam
07/12/2021, 8:32 PMCREATE TYPE "public"."TestType" AS ENUM ('FOO', 'BAR', 'BAZ');
We manually altered these files to take out the schema so our automated tests could run correctly
CREATE TYPE "TestType" AS ENUM ('FOO', 'BAR', 'BAZ');
But altering the migration manually results in a warning in prisma and probably isn't the best thing to do for our production systems I would think?iamtheworstdev
07/13/2021, 7:58 PMmigrate
doesn't try to create tables for those modelsiamtheworstdev
07/13/2021, 8:00 PMCarlos Gomez
07/14/2021, 7:34 PMprisma migrate deploy
(per the docs)
3) run tests (1 test does a create
, then a findAll
, and it's passing)
After running prisma migrate deploy
, my postgres container shows an error (in thread)Mischa
07/15/2021, 6:30 AMJon Deibel
07/16/2021, 2:59 PMAlexander Braunreuther
07/19/2021, 7:05 AMsven
07/27/2021, 1:18 PM@unique
) through pgbouncer as we always do (and it usually works well)
2. The migrate failed because we had duplicate entries
3. We removed the duplicate entries and re-ran migrate deploy
4. Then we saw Error querying the database: db error: ERROR: relation "_prisma_migrations" already exists
5. We deleted the failed migration from the table and re-ran migrate deploy
6. Still the same error from 4.
7. We ran migrate deploy directly against the database (no pgbouncer) and this worked!
We solved it, but I thought maybe this helps someone, so there it is.Daan Helsloot
08/02/2021, 8:15 AMprisma migrate dev --name init
command which gives me the ouput found in the attachment. Is there a way to use the new functionality without wiping the entire database? Many thanks!Tanmay Naik
08/07/2021, 11:09 AMTanmay Naik
08/07/2021, 11:11 AMMischa
08/10/2021, 9:28 AMRichard Dunlap
08/12/2021, 4:01 PMNeil Oliver
08/19/2021, 8:55 AMSKhan
08/26/2021, 2:48 AMprisma generate
, in the schema.prisma file, @@unique
row is updated with a name property. Now, typescript is screaming about errors in the generated file: node_modules/.prisma/client/index.d.ts
. How should I proceed?
git push origin dbMigrationsReset
node_modules/.prisma/client/index.d.ts:18304:5 - error TS1131: Property or signature expected.
18304 GoalBoard.goalOwnerId_isActive_unique?: GoalBoardGoalBoard.goalOwnerId_isActive_uniqueCompoundUniqueInput
~~~~~~~~~
node_modules/.prisma/client/index.d.ts:18304:43 - error TS1109: Expression expected.
18304 GoalBoard.goalOwnerId_isActive_unique?: GoalBoardGoalBoard.goalOwnerId_isActive_uniqueCompoundUniqueInput
~
node_modules/.prisma/client/index.d.ts:18347:5 - error TS1131: Property or signature expected.
18347 Invite.fromGBId_toGBId_unique?: InviteInvite.fromGBId_toGBId_uniqueCompoundUniqueInput
~~~~~~
node_modules/.prisma/client/index.d.ts:18347:35 - error TS1109: Expression expected.
18347 Invite.fromGBId_toGBId_unique?: InviteInvite.fromGBId_toGBId_uniqueCompoundUniqueInput
~
node_modules/.prisma/client/index.d.ts:18348:3 - error TS1128: Declaration or statement expected.
18348 }
~
node_modules/.prisma/client/index.d.ts:18547:5 - error TS1131: Property or signature expected.
18547 TaskFrequency.taskId_completedOn_unique?: TaskFrequencyTaskFrequency.taskId_completedOn_uniqueCompoundUniqueInput
~~~~~~~~~~~~~
node_modules/.prisma/client/index.d.ts:18547:45 - error TS1109: Expression expected.
18547 TaskFrequency.taskId_completedOn_unique?: TaskFrequencyTaskFrequency.taskId_completedOn_uniqueCompoundUniqueInput
~
node_modules/.prisma/client/index.d.ts:18548:3 - error TS1128: Declaration or statement expected.
18548 }
~
node_modules/.prisma/client/index.d.ts:20835:33 - error TS1005: '=' expected.
20835 export type GoalBoardGoalBoard.goalOwnerId_isActive_uniqueCompoundUniqueInput = {
~
node_modules/.prisma/client/index.d.ts:20835:81 - error TS1005: ';' expected.
20835 export type GoalBoardGoalBoard.goalOwnerId_isActive_uniqueCompoundUniqueInput = {
~
Anthony Campolo
09/02/2021, 12:22 AMyarn rw prisma migrate dev
, (which is basically just a wrapper around prisma migrate dev
) with a Supabase database and I’m getting this error:
Error: Database error
Error querying the database: db error: ERROR: unexpected response from login query
0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:375
1: migration_core::api::DevDiagnostic
at migration-engine/core/src/api.rs:89
My Prisma schema:
datasource DS {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
binaryTargets = "native"
}
model User {
id Int @id @default(autoincrement())
githubId Int
handle String @unique
email String @unique
createdAt DateTime @default(now())
}
model Repository {
id Int @id @default(autoincrement())
githubId Int
fullName String
createdAt DateTime @default(now())
}
Redacted .env
file:
DATABASE_URL=<postgres://postgres:password@db.xxxx.supabase.co:6543/postgres>
SUPABASE_URL=<https://xxxx.supabase.co>
SUPABASE_KEY=xxx
SUPABASE_JWT_SECRET=xxx
Josef Henryson
09/07/2021, 7:55 AMMarvin
09/13/2021, 12:22 PMSchuyler Ankele
09/14/2021, 10:39 PMJosef Henryson
09/23/2021, 2:58 PM