Skip to content

feat: Add check to disable migration warning for specific models #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@ Migrations will look for cursor fields in your models in this order:
If no cursor is found for a model with encrypted fields, the generator will
throw an error when running `prisma generate`.

### Disabling Migration Warnings

You can use the new environment variable `DISABLE_MIGRATION_WARNING` to disable the
warning about missing cursors. However, if a model lacks a suitable cursor and this
warning is disabled, the `prisma generate` command will still fail to run.


## Key management

This library is based on [@47ng/cloak](https://github.com/47ng/cloak), which comes
Expand Down
7 changes: 6 additions & 1 deletion src/dmmf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export function analyseDMMF(input: DMMFDocument): DMMFModels {
const dmmf = dmmfDocumentParser.parse(input)
const allModels = dmmf.datamodel.models

const disabledWarningsModels = process.env.DISABLE_MIGRATION_WARNING
? process.env.DISABLE_MIGRATION_WARNING.split(',')
: []

return allModels.reduce<DMMFModels>((output, model) => {
const idField = model.fields.find(
field => field.isId && supportedCursorTypes.includes(String(field.type))
Expand Down Expand Up @@ -120,7 +124,8 @@ export function analyseDMMF(input: DMMFDocument): DMMFModels {

if (
Object.keys(modelDescriptor.fields).length > 0 &&
!modelDescriptor.cursor
!modelDescriptor.cursor &&
!disabledWarningsModels.includes(model.name)
) {
console.warn(warnings.noCursorFound(model.name))
}
Expand Down