1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[Prisma] db migrate時に毎回データを削除されそうになる

Posted at
環境
prisma: ^4.7.1
db: postgresql(supabase)

問題

以前prisma-postgresqlの拡張機能を試しました。

これ以降 prisma migrate devするたびにデータが失われることが求められます。これは非常に困る。

実際のエラー

The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.

It should be understood as the set of changes to get from the expected schema to the actual schema.

[+] Added extensions
  - uuid-ossp

- The following migration(s) are applied to the database but missing from the local migrations directory: 20230xxxxxx_migration

✔ We need to reset the "public" schema at "db.xxxxx.supabase.co:5432"
Do you want to continue? All data will be lost. … no

解決法

正攻法でない気がしますが、とりあえず拡張の部分を消すとデータの削除は防げます。

schema.prisma
generator client {
  provider        = "prisma-client-js"
  // 削除 previewFeatures = ["postgresqlExtensions"]
}

datasource db {
  provider   = "postgresql"
  url        = env("DATABASE_URL")
  // 削除 extensions = [citext(schema: "public"), uuid_ossp(map: "uuid-ossp")]
}

やったこと

dbからschemapullしたあとにmigrateしてもダメでした。

  1. prisma db pull
  2. prisma migrate dev

おそらくsupabase側のextensionsと衝突してる気がします。
ちなみにsupabase側のuuid-osspは停止できなかった。
スクリーンショット 2023-02-09 18.27.56.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?