Yunbo
04/20/2022, 8:41 PMnpx prisma migrate dev --name "init"
3. threw an error saying type "citext" does not exist
4. npx prisma migrate resolve --rolled-back "xxxx-init"
5. it's rolled back
6. modified "xxxx-init" migration sql by adding
CREATE EXTENSION IF NOT EXISTS citext;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
7. npx prisma migrate deploy
8. All migrations have been successfully applied.
9, added on column in one table in schema.prisma
10. npx prisma migrate dev --name "add_type_in_flavor"
11. It says
The migration `xxxx-init` was modified after it was applied.
โ We need to reset the PostgreSQL database "postgres" at "localhost:5439".
Do you want to continue? All data will be lost.
i feel like i did something wrong on around step 3 when I tried to resolve the failed migration.
How can I resolve this issue without losing data?Error: P3008
The migration `xxxx-init` is already recorded as applied in the database.
fix the migration state manually
?Casey Chow
04/20/2022, 8:46 PMYunbo
04/20/2022, 8:49 PM_prisma_migrations
table and update columns such as finished_at
?Casey Chow
04/20/2022, 8:51 PMYunbo
04/20/2022, 8:53 PMCasey Chow
04/20/2022, 8:56 PMYunbo
04/20/2022, 9:02 PMnpx prisma migrate resolve --applied "xxxx-init"
and it says
Error: P3008
The migration `xxxx-init` is already recorded as applied in the database.
interestingly, when i went to _prisma_migrations
table and looked at the row, it's finished_at
value was null. which is strange....
logs (in the table) says
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: xxxx_init
Database error code: 42704
Database error:
ERROR: type "citext" does not exist
Position:
[1m123[0m
[1m124[0m -- CreateTable
[1m125[0m CREATE TABLE "accounts" (
[1m126[0m "id" SERIAL NOT NULL,
[1m127[0m "status_id" INTEGER NOT NULL DEFAULT 1,
[1m128[1;31m "email" CITEXT NOT NULL,[0m
DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42704"), message: "type \"citext\" does not exist", detail: None, hint: None, position: Some(Original(3654)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("parse_type.c"), line: Some(274), routine: Some("typenameType") }
0: sql_migration_connector::apply_migration::apply_script
with migration_name="xxxx_init"
at migration-engine/connectors/sql-migration-connector/src/apply_migration.rs:104
1: migration_core::state::ApplyMigrations
at migration-engine/core/src/state.rs:185
Casey Chow
04/20/2022, 9:08 PMtornros
04/20/2022, 9:08 PMYunbo
04/20/2022, 9:09 PMnpx prisma migrate dev
The migration `xxxx-init` was modified after it was applied.
โ We need to reset the PostgreSQL database "postgres" at "localhost:5439".
Do you want to continue? All data will be lost