splitting into multiple schema.rs
forest1102 opened this issue · 1 comments
forest1102 commented
Your project helps a lot.
One feature I want is splitting into multiple schema.rs.
For instance, making the following diesel.toml
[[print_schema]]
file = "db_company/src/schema.rs"
filter = { only_tables = ["^companies$"] }
[[print_schema]]
file = "db_user/src/schema.rs"
filter = { only_tables = ["^users$"] }
Then, the companies
schema info is written in db_company/src/schema.rs
, while the users
schema info goes to db_user/src/schema.rs
.
Current Behavior
print_schema field only allows only on schema info.
So, what I do right now is select one print_schema and comment out others like the following files.
[print_schema]
file = "db_company/src/schema.rs"
filter = { only_tables = ["^companies$"] }
# [print_schema]
# file = "db_user/src/schema.rs"
# filter = { only_tables = ["^users$"] }
Motivation
- Readability
- By splitting schema.rs, we can easily search definition of tables.
- Build Performance
- This feature will parallelize building schema.rs. which will result in better build performance.
How to do
- make print_schma field in diesel.toml to either single or multiple print_schema
- edit print_schema.rs to run multiple time.
Originally posted by @forest1102 in #3715