My whole team is using docker so we have similar versions, some people are on Linux and some on Mac. When I call rails db:schema:dump
I see few discrepancies in the resulting diff:
The 1st kind is type casting like this:
- t.check_constraint "status::text = ANY (ARRAY['active'::character varying, 'inactive'::character varying, 'deleted'::character varying]::text[])", name: "correct_status"
+ t.check_constraint "status::text = ANY (ARRAY['active'::character varying::text, 'inactive'::character varying::text, 'deleted'::character varying::text])", name: "correct_status"
Which appears to be completely inconsequential. As mentioned above, we use the docker, but I even updated PostgreSQL on my host to the same version as docker (16.4-1), and purged everything related to PostgreSQL on the host machine (for example, pg_dump
no longer exists on the host) – still no change.
Another kind of discrepancy is
- t.check_constraint "checksum IS NOT NULL", name: "active_storage_blobs_checksum_is_not_null", validate: false
+ t.check_constraint "checksum IS NOT NULL", name: "active_storage_blobs_checksum_is_not_null
(in active_storage_blobs, which we obviously don’t ever touch).
I scanned through stack overflow and all posts suggest keeping the versions the same, but this does not help. LLMs are also useless. There appears to be no ENV nor locale that could influence it.
I’ve hit a brick wall.
0
Ok, (with help) I got the answer:
It’s the version of the libraries during the pg native extension build that matters. So, updating your PostgreSQL packages (so it matches the versions of your teammates) is important, but not sufficient!
What I had to do is:
- upgrade the Postgres packages (it was version 16 for me)
- drop all gems from the system
gem uninstall -aIx
(I’m guessing removing justpg
could suffice) - installing the
pg
gem again, it does build the native extension using currently available libs.
And, to answer the original question: the discrepancies apparently come from libpq-dev
that was available when I first installed the pg
gem.