Skip to content

Capturing database default values on initial creation - #29

Merged
thijskok merged 1 commit into
mainfrom
fixed-capturing-fields-after-creation
Jul 23, 2026
Merged

Capturing database default values on initial creation#29
thijskok merged 1 commit into
mainfrom
fixed-capturing-fields-after-creation

Conversation

@thijskok

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI 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.

Pull request overview

This PR ensures revisions/diffs capture database-assigned default column values immediately after a model is created, while preserving any unsaved in-memory mutations made right after creation.

Changes:

  • Added coverage to assert DB defaults (e.g., votes, views, nullable content) are present in the initial revision snapshot when revision-on-create is enabled.
  • Updated revision snapshot building to backfill missing attributes from a freshly loaded instance when wasRecentlyCreated is true, without overwriting in-memory changes.
  • Tightened/clarified several event/docblock descriptions in HasRevisions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/RevisionDiffTest.php Adds a regression test ensuring diffing right after create preserves unsaved mutations.
tests/CreatingRevisionsTest.php Adds a test asserting initial revisions include DB default values when enabled on create.
src/Revisioner.php Backfills DB-assigned defaults for recently-created models by merging in fresh() attributes.
src/Concerns/HasRevisions.php Docblock clarifications for rollback-related events and diff description.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@thijskok
thijskok requested a review from Frankisgek July 22, 2026 14:26
@thijskok
thijskok merged commit 2edfd2e into main Jul 23, 2026
7 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.

3 participants