Arun Kumar
07/30/2021, 8:18 AMnpx prisma migrate dev
command.
Error: P3006
Migration `20210729200626_changing_the_id_and_id_referral_to_int` failed to apply cleanly to the shadow database.
Error:
Database error
Error querying the database: db error: ERROR: syntax error at or near ","
0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
at migration-engine\connectors\sql-migration-connector\src\flavour\<http://postgres.rs:367|postgres.rs:367>
1: sql_migration_connector::validate_migrations
at migration-engine\connectors\sql-migration-connector\src\<http://lib.rs:322|lib.rs:322>
2: migration_core::api::DevDiagnostic
at migration-engine\core\src\<http://api.rs:89|api.rs:89>
Error: P3006
Migration `20210729200626_changing_the_id_and_id_referral_to_int` failed to apply cleanly to the shadow database.
Error:
Database error
Error querying the database: db error: ERROR: syntax error at or near ","
0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
at migration-engine\connectors\sql-migration-connector\src\flavour\<http://postgres.rs:367|postgres.rs:367>
1: sql_migration_connector::validate_migrations
at migration-engine\connectors\sql-migration-connector\src\<http://lib.rs:322|lib.rs:322>
2: migration_core::api::DevDiagnostic
at migration-engine\core\src\<http://api.rs:89|api.rs:89>
PS C:\Users\ArunKadari\Documents\projects\cradleAPI> npx prisma migrate dev
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": PostgreSQL database "cradle-local", schema "public" at "localhost:5432"
? - The migration `20210729200626_changing_the_id_and_id_referral_to_int` failed.
- The migration `20210729200626_changing_the_id_and_id_referral_to_int` was modified after it was applied.
We need to reset the PostgreSQL database "cradle-local" at "localhost:5432".
Do you want to continue? All data will be lost. » (y/N)
Ryan
07/30/2021, 10:58 AMArun Kumar
07/30/2021, 11:09 AM@default(autoinrement())
and ran the migrate dev
command. It generated a serial type and thrown an error that serial type doesn't exits. Then I manually edited the migration file to remove the serial type and made it as integer.Ryan
07/30/2021, 11:19 AMArun Kumar
07/30/2021, 11:31 AMSERIAL
type in the migration file but the migrate dev
command didn't throw any error.
model test2 {
id Int @id @default(autoincrement())
idReferral Int @unique
}
-- CreateTable
CREATE TABLE "test2" (
"id" SERIAL NOT NULL,
"idReferral" INTEGER NOT NULL,
PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "test2.idReferral_unique" ON "test2"("idReferral");
Ryan
07/30/2021, 11:35 AMserial
will work and not throw any error. In your model was there any change you made before serial?Arun Kumar
07/30/2021, 11:41 AMserial
it's altering the migration file to a sequence
. For the other models the migration file is like below.
ALTER TABLE "emergencyInfo" ALTER COLUMN "id" SET DEFAULT nextval('emergencyinfo_id_seq');
Database error code: 42704
ALTER TABLE "test2" DROP CONSTRAINT "test2_pkey",
ALTER COLUMN "id" SET DATA TYPE BIGSERIAL,
ADD PRIMARY KEY ("id");
Database error:
ERROR: type "bigserial" does not exist
Here is the schema state when this error occured
model test2 {
id BigInt @id @default(autoincrement())
idReferral Int @unique
}
Ryan
07/30/2021, 12:13 PMArun Kumar
07/30/2021, 12:25 PMRyan
07/30/2021, 12:39 PM