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

Generate migrations from blueprint #56

Closed
duncanmcclean opened this issue Jul 24, 2021 · 4 comments · Fixed by #57
Closed

Generate migrations from blueprint #56

duncanmcclean opened this issue Jul 24, 2021 · 4 comments · Fixed by #57

Comments

@duncanmcclean
Copy link
Member

What would you like to see added?

This is something I've told a couple of people about but essentially, my plan at some point is to build a way to automatically generate database migrations, based on field configurations from your blueprint.

How would it work?

It would be smart enough to know which column type each builtin fieldtype should be and it would be clever to change that if max_assets is defined.

If we don't know which column type to use (eg. custom fieldtype) we could maybe just leave it as a string/json column and give the user an error?

This would be some sort of command, like: php please runway:migration order

Considerations

  • It would also need to know how to handle changes in a blueprint (eg. field added, field removed, field config changed, etc). I guess in that case we'd just need to do a comparison to what's there and make a new migration with the relevant changes.

Is there a workaround you can use in the meantime?

You could just do it by hand, which is a bit of a sucky option because you then have to define everything twice.

Priority wise - where's this feature for you?

This is just a nice to have. I can deal without.

@johncarter-
Copy link
Contributor

I was thinking about this the other day, nearly started a PR.

It would also be good to have a php please runway:blueprint Order. Where the schema of the model could be mapped or best guessed to a fieldtype and generate a blueprint based on that.

Both are useful, because sometimes you already have an app with your migrations and models already existing, and other times on greenfield projects it would be good to use the blueprint builder to make the migration for you.

@duncanmcclean
Copy link
Member Author

Yeah that's a good idea. Didn't think about the other side of it.

@johncarter-
Copy link
Contributor

It would be a bit of guess work on what column is what fieldtype, but defaulting to text would be okay.

Especially if the Statamic PR for addons registering their own blueprints gets merged, then you can go in and make the tweaks in the CP blueprint builder.

@duncanmcclean
Copy link
Member Author

I've created a pull request for creating migrations from blueprints, it's pretty much ready to merge, just need to check over it again.

Would you mind opening another issue for the 'migration > blueprint' flow? As this one will be closed when the PR is merged.

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 a pull request may close this issue.

2 participants