Skip to content

fix(sdk): omit updatedAt ignore from Prisma schemas - #2931

Merged
ymc9 merged 3 commits into
zenstackhq:devfrom
clean99:contrib/updatedat-ignore-prisma
Nov 27, 2026
Merged

ymc9 merged 3 commits into
zenstackhq:devfrom
clean99:contrib/updatedat-ignore-prisma

Conversation

@clean99

@clean99 clean99 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

@updatedAt(ignore: [views]) is supported by ZModel, but its ignore argument reaches the generated Prisma schema and causes P1012 during migrations or db push.

Filter that argument at the Prisma output boundary. The timestamp attribute and ZenStack's TypeScript metadata remain intact. The regression now lives in the existing CLI Prisma-schema generator suite and covers a populated ignore list, an empty list, plain @updatedAt, and neighboring @default/@map attributes.

pnpm --filter @zenstackhq/sdk build && pnpm --filter @zenstackhq/cli test test/prisma-schema-gen.test.ts

The focused regression, related Prisma-generator/CLI tests, workspace lint, owning build/typechecks, and SQLite CLI migration/push probes pass. Full CLI and regression suites have the same 78 and 251 failed tests on an independently installed base checkout with matching Node/pnpm/dependency versions, including TypeScript resolution, native SQLite bindings, and Prisma command failures. The PostgreSQL/MySQL test matrix and ORM timestamp-update behavior were not validated.

Fixes #2930.

Summary by CodeRabbit

  • Bug Fixes
    • Prisma schema generation now omits ignore arguments from @updatedAt attributes while preserving other attributes.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ff8a2e4 and 8484a75.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The Prisma schema generator now omits the ZenStack-only ignore argument from generated @updatedAt attributes. A regression test checks the generated output for non-empty, empty, and absent ignore arguments.

Changes: UpdatedAt Argument Filtering

Layer / File(s) Summary
Filter and verify @updatedAt arguments
packages/sdk/src/prisma/prisma-schema-generator.ts, packages/cli/test/prisma-schema-gen.test.ts
The generator filters resolved ignore arguments from @updatedAt. The test checks that other attributes remain and that @updatedAt() is generated when ignore is non-empty, empty, or absent.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: ymc9

Merge Risk: Minimal · previous review ff8a2

The change stops the ZenStack-only ignore argument from reaching the generated Prisma schema, which should fix the P1012 validation error in migrate and db push. The change is small and covered by a focused test, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(sdk): omit updatedAt ignore from Prisma schemas" matches the main change. The SDK's Prisma schema generator now drops the ZenStack-only ignore argument from @updatedAt in the genera…
Linked Issues check Passed Issue #2930 requires that the generated Prisma schema omit the ZenStack-only ignore argument from @updatedAt. The TS schema must keep it. At the reviewed head, makeFieldAttribute in packages/sdk…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes the Prisma generator source (a single filter on ignore for @updatedAt, about +3/-1 lines) and adds regression tests for #2930. The regression test …
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "fix(sdk): omit updatedAt ignore from Prisma schemas" matches the main change. The SDK's Prisma schema generator now drops the ZenStack-only ignore argument from @updatedAt in the generated Prisma schema, and a regression test covers this. The title names the affected package, the behavior, and the target output. It is specific and not vague.

Full details: Linked Issues check

Explanation

Issue #2930 requires that the generated Prisma schema omit the ZenStack-only ignore argument from @updatedAt. The TS schema must keep it. At the reviewed head, makeFieldAttribute in packages/sdk/src/prisma/prisma-schema-generator.ts filters out args where attrName === '@updatedAt' && arg.$resolvedParam?.name === 'ignore' before calling makeAttributeArg. Other args, including @default and @map on neighboring fields, follow the unchanged path. The TS schema generator and runtime are not changed by this PR, so ignore metadata stays intact. Regression coverage (populated list, empty list, plain @updatedAt, neighboring @default/@map) is present in the PR. The author reports the focused regression and SQLite migrate/push probes pass. Limits: I did not run the tests. For an empty or plain @updatedAt, the test expectation reportedly renders @updatedAt() rather than the bare @updatedAt named in the issue. This is a textual difference that does not change the ignore-list behavior. PostgreSQL/MySQL validation and ORM timestamp-update behavior were not validated by the author. Issue #2379 (fields) is separate work and is not required here.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes the Prisma generator source (a single filter on ignore for @updatedAt, about +3/-1 lines) and adds regression tests for #2930. The regression test covers the populated list, empty list, plain @updatedAt, and neighboring @default/@map cases, which are the issue's scenarios. The PR description is documentation only. No unrelated files or behavior changes were identified in the reviewed summary. The reviewed head source confirms the filter is the only change in makeFieldAttribute. The diff tool did not return a text diff in this review, so the change scope rests on the summary and the head file read.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between cc4c6f6 and ff8a2e4.

Files selected for processing: 1

  • packages/cli/test/prisma-schema-gen.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@sanny-io sanny-io left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the test should be moved to packages/cli/test/prisma-schema-gen.test.ts

@ymc9

ymc9 commented Nov 27, 2026

Copy link
Copy Markdown
Member

Thanks for the fix @clean99 !

@ymc9
ymc9 enabled auto-merge (squash) November 27, 2026 03:34
@ymc9
ymc9 merged commit 3ac2e4a into zenstackhq:dev Nov 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] @updatedAt(ignore: [...]) is emitted into the Prisma schema, so zen migrate dev fails with P1012

3 participants