Generate schema.rs with cargo build

Would it be a good idea to generate schema.rs when running cargo build and not keep track of schema.rs inside of a VCS?

If so what would be the best way? What would the build.rs look like (if it is used)?

Normally schema.rs is meant to be included in your VCS, because it represents something at the current code status that does not change randomly.

If you really want to generate it at build time running diesel print-schema via shell command is probably the easiest way.

Isn’t that the whole point of migrations though? Doesn’t that make it redundant?

At least in my opinion having a schema.rs in your VCS is not redundant, because migrations are not required. (For example you could develop against a existing database).
Anyway we’ve currently no plan to split out the print-schema related code from diesel-cli, which would be required to support generating the schema from a build.rs without calling a shell command. If anyone want’s to do that as a third party crate, go for it.

Ok.

I never thought of this though and I don’t think it would be useful regardless of whether schema.rs is redundant or not.