跳到主要內容

不支援的資料庫功能 (Prisma Migrate)

Prisma Migrate 使用 Prisma schema 來確定要在資料庫中建立哪些功能。然而,有些資料庫功能 無法在 Prisma schema 中表示 ,包括但不限於

  • 儲存過程
  • 觸發器
  • 檢視
  • 部分索引

要將不支援的功能新增到資料庫中,您必須 自定義遷移,然後在應用它之前包含該功能。

提示

Prisma schema 能夠表示 不支援的欄位型別原生資料庫函式

警告

本指南**不適用於 MongoDB**。
代替 migrate devdb push 用於 MongoDB

自定義遷移以包含不支援的功能

要自定義遷移以包含不支援的功能:

  1. 使用 --create-only 標誌生成新的遷移而不應用它

    npx prisma migrate dev --create-only
  2. 開啟生成的 migration.sql 檔案並新增不支援的功能——例如,部分索引

    CREATE UNIQUE INDEX tests_success_constraint
    ON posts (subject, target)
    WHERE success;
  3. 應用遷移

    npx prisma migrate dev
  4. 將修改後的遷移提交到版本控制。

© . This site is unofficial and not affiliated with Prisma Data, Inc.