What Postgres says about the tables an application owns.
Two callers ask these two questions, and they must not be allowed to disagree.
Ithibati.Migration asks them before it points a foreign key at somebody's account table, and
Ithibati.Doctor asks them afterwards, to say whether what was built still matches what is
configured. A second copy of either query would answer the same question differently the first
time somebody corrected one of them.
Everything here takes its repo and prefix as arguments. The migration has Ecto.Migration's
repo/0 and prefix/0 to hand, and nothing outside a migration does.
Summary
Functions
A column's type and whether one unique index covers it alone, or nil when there is no such
column.
Whether a table's key column can carry Ithibati's foreign keys. It answers
{:ok, description}, or a sentence saying what is wrong.
A table's name as a message should show it, carrying the prefix when there is one.
The oid of a table, or nil when there is none under that prefix.
Functions
A column's type and whether one unique index covers it alone, or nil when there is no such
column.
A domain resolves to what it is built on, because that is what a foreign key compares against.
The index has to cover that column and nothing else, and it must not be partial, which Postgres
refuses as a reference target. indnkeyatts counts key columns only, so
PRIMARY KEY (id) INCLUDE (email) still qualifies.
Whether a table's key column can carry Ithibati's foreign keys. It answers
{:ok, description}, or a sentence saying what is wrong.
The judgement travels with the query for the reason the query travelled here. The migration decides this before it builds and the doctor decides it afterwards, and the two disagreeing is worse than either being wrong. A wrong answer out of the SQL is loud. A disagreement about which types are acceptable means one of them blesses a database the other refuses.
A table's name as a message should show it, carrying the prefix when there is one.
The oid of a table, or nil when there is none under that prefix.
This resolves the name the way Ecto resolves the REFERENCES clause it emits: qualified when
there is a prefix, and through the search path when there is not. Postgres does the quoting
rather than Ithibati, so a table whose name is not lower case answers for itself instead of
being downcased into a different one.