This package contains the crates.io database schema as derived by diesel print-schema
from the database after all the migrations have been applied.
After creating new migrations (via diesel migration generate
), you can update
the schema by running:
diesel print-schema > crates/crates_io_database/src/schema.rs
Note that there is also a schema.patch
file in this package, since the output
of diesel-cli
needs to be tweaked a little for our purposes. For example,
it currently does not support printing materialized views in the same way as
regular tables, so we have to manually add them to the schema file.
If you need to update the patch file, you can do so by following these steps:
- prefix
patch_file = "src/schema.patch"
indiesel.toml
with a#
to comment it out. - use
diesel print-schema
and save the output tosrc/schema.rs.orig
- use
patch -o src/schema.rs src/schema.rs.orig src/schema.patch
to apply the patch file and solve remaining issues in thesrc/schema.rs
file - use
diff -Naur src/schema.rs.orig src/schema.rs
to generate the new content for thesrc/schema.patch
file - enable the
patch_file
option in thediesel.toml
file again.