Assuming all databases of a rails 7.0.3 application are on the same server (be they replicas or not)
- Where primary database (
app_development) has a tableshop - a secondary database (
appusers_development) has a tablerole - there is a third database (
applocal_development) that will need to connect as well.
If a migration is created in the secondary database, where
t.references :shop, index: true, null: false, foreign_key: true
t.references :role, index: true, null: false, foreign_key: true
this migration will not pass, as postgresql has no knowledge of the connection to the other database: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "shops" does not exist
Different users exist for main database deploy_root and replicas deploy_readonly.
It does not appear that this is set out in rails functionalities, thus how can it be accomplished with postgresql