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

Autodiscover #42

Open
ryanhiebert opened this issue Sep 13, 2023 · 2 comments
Open

Autodiscover #42

ryanhiebert opened this issue Sep 13, 2023 · 2 comments

Comments

@ryanhiebert
Copy link
Collaborator

Much of the time I'm able to easily determine what the safe property of a migration should be. Some categories of operations are so clear that we should be able to discover it algorithmically. There are certainly limitations to what can be automatically discovered, and I'm not sure how it should interplay with the default. Or if it's even worthwhile. But it keeps coming up in my mind and I wanted to create an issue here as a place to collect thoughts on the idea.

@tim-schilling
Copy link
Member

We could start with the the basics:

before_deploy

  • Add model
  • Add nullable field

after_deploy

  • Remove model
  • Remove field
  • Add unique constraint
  • Add index

@ryanhiebert
Copy link
Collaborator Author

ryanhiebert commented Sep 13, 2023

Those are good places to start, and it's going to have to be OK to not include all the possibilities. There are some that we'll miss, but there are some that we can't discover.

With the pre-commit hook now merged, it makes me wonder how to implement this. Autodiscovery would be about impossible to detect in a hook remotely similar to the one we have if the property is not included in the migration. One possibility might be to override or have a custom makemigrations command that includes it. It feels like we may have suggested that previously, but that sounds like a good way to enable autodiscovery.

It might even open things up for automatically splitting a new migration into two where we notice that some are before_deploy and some are after_deploy.

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

No branches or pull requests

2 participants