Skip to content
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

Add cast on migration #53

Merged
merged 1 commit into from
Apr 7, 2021
Merged

Add cast on migration #53

merged 1 commit into from
Apr 7, 2021

Conversation

vdauchy
Copy link
Contributor

@vdauchy vdauchy commented Mar 24, 2021

Hi @rubenvanassche ,

This is my PR following #49 .

This make the migrations 'castable' using the global casts.

NOTES:

  • As this change the Type passed to the update's closure, this might be concidered as breaking change.
  • There is many use of optional() helper, those could be replaced by ?-> when php 8 is only supported.
  • To reduce breaking change casts are only set on objects created or updated.
  • Since now we have access to settings classes in migrations, we could enforce that groups and names match existing group class and there properties (to detect typos or non exting group/properties), maybe as a futur feature...

@vdauchy vdauchy marked this pull request as draft March 25, 2021 11:39
@vdauchy vdauchy marked this pull request as ready for review March 25, 2021 14:33
Copy link
Member

@rubenvanassche rubenvanassche left a comment

Choose a reason for hiding this comment

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

This is looking great! Just one small comment

src/Migrations/SettingsMigrator.php Outdated Show resolved Hide resolved
@rubenvanassche
Copy link
Member

rubenvanassche commented Mar 30, 2021

As this change the Type passed to the update's closure, this might be concidered as breaking change.

Yeah, I'm not sure how many users already use this functionality so tagging a major version is maybe a big step

There is many use of optional() helper, those could be replaced by ?-> when php 8 is only supported.

Hmm, makes me want to make the package PHP 8 only 😄

To reduce breaking change casts are only set on objects created or updated.

👍

Since now we have access to settings classes in migrations, we could enforce that groups and names match existing group class and there properties (to detect typos or non exting group/properties), maybe as a futur feature...

That's actually a great idea!

@rubenvanassche
Copy link
Member

Looking great @vdauchy, thanks!

@rubenvanassche rubenvanassche merged commit 4b2be18 into spatie:master Apr 7, 2021
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.

None yet

2 participants