umbraco / UmbracoDocs

The official Umbraco Documentation
https://docs.umbraco.com
MIT License
266 stars 770 forks source link

Should generated models files be tracked in source control? #1990

Closed dhymik closed 4 years ago

dhymik commented 4 years ago

This is the page with issues: https://github.com/umbraco/UmbracoDocs/edit/master/Getting-Started/Code/Source-Control/index.md

In the App_Data section, Models Builder sub section, of the Source Control page, it says:

App_Data: The models are generated in the /App_Data folder of your project (or can be configured to be in a different folder or project), allowing you to track changes to the models in source/version control.

And further down, in the Controllers/Classes/Custom Code section, it says:

Models generated by Modelsbuilder in API or App_Data mode... should be added to source/version control.

But Models Builder is a "code after" solution, it auto generates files based on doc types in the database, so the source is the database, and the corresponding autogenerated .cs files should not be under source control, or should they actually? Afaik, only developer generated partial class files (extending the auto generated models) should be included in source control.

In the DocumentType - Backoffice Structure Changes section further down, it is explained that changes to doc types are stored in the database, so in order to track those changes, a database dump would need to be created and source controlled. This is the only way to source control doc types, and doc types, in turn, control the auto generated models files.

What do you think?

nul800sebastiaan commented 4 years ago

But Models Builder is a "code after" solution, it auto generates files based on doc types in the database, so the source is the database, and the corresponding autogenerated .cs files should not be under source control, or should they actually?

Any querying in templates will fail until the files are regenerated.

a database dump would need to be created and source controlled. This is the only way to source control doc types, and doc types, in turn, control the auto generated models files.

For v8 we don't have the Umbraco Deploy product on premise yet, but that would be another way. There's other plugins that can facilitate this as well.

Ultimately, there's loads of room for discussion on this, but the docs describe how we think you should work and of course people deviate from this all the time, which is great!