#3201·diesel

diesel_cli: joinable vanishes when a partition is added in a migration even on a fresh database (no redo)

Author: najtinCreated Jun 10, 2022Updated Sep 24, 2026
Labelsbugcli

Setup

Versions

  • Rust: 1.60.0
  • Diesel CLI: 2.0.0-rc.0
  • Diesel: not needed
  • Database: postgres 14.3 (docker)
  • Operating System: Manjaro

Problem Description

Adding a new partition to a partitioned table in a migration causes diesel to stop generating the joinable macros. Note that the joinables where created before the new migration was added.

What are you trying to accomplish?

I just wanted to get partitions to work with Diesel. As stated in https://github.com/diesel-rs/diesel/issues/2817 adding partitions will result in an empty schema.rs on diesel_cli 1.4.1, so i updated to diesel_cli 2.0.0-rc.0. I also opened another issue with a similar but not the same problem https://github.com/diesel-rs/diesel/issues/3200 It might be that these are closely related.

What is the expected output?

The expected output is a schema.rs with joinables even after a partition is added.

What is the actual output?

Some joinables are missing in the output.

Are you seeing any additional errors?

No

Steps to reproduce

This is the project before any migrations: https://github.com/najtin/diesel_add_partition/tree/d853e16196b427277c4064ff7bf5ac5bb693f7a5 Here you can see the differences in the schema.rs https://github.com/najtin/diesel_add_partition/commit/9fd28ff02cf0514e7edc132c3827d8f902f25a2f#diff-cfb402317f9a1267396cd28c72ab83f4236dca6ebbf2f87ed850f2b82da5862dL27-L29

bash
git clone https://github.com/najtin/diesel_add_partition
git checkout d853e16196b427277c4064ff7bf5ac5bb693f7a5
# change .env to your needs
nano .env
diesel migration run
# take a look at the joinables from schema.rs
less src/schema.rs
# start over with a fresh database or run diesel migration revert
mkdir migrations/2022-06-10-100936_add_partition_tables/
echo "drop table if EXISTS course_user_partiton_22_ss CASCADE;" > migrations/2022-06-10-100936_add_partition_tables/down.sql
echo "CREATE TABLE course_user_partiton_22_ss PARTITION OF course_user FOR VALUES FROM (2210000000000000000) TO (2220000000000000000);" > migrations/2022-06-10-100936_add_partition_tables/up.sql
diesel migration run
# notice the missing joinables
less src/schema.rs

Checklist

  • This issue can be reproduced on Rust's stable channel. (Your issue will be closed if this is not the case)
  • This issue can be reproduced without requiring a third party crate

Thank you very much for this awesome crate!