Create foreign key on foreign table in postgresql
You can't create a FOREIGN KEY constraint that references a table in either a different database or through a foreign data wrapper. A foreign key must reference a (base) table* in the same database (a base table: not a view, not a foreign data wrapper table).

If you can change your design to have these 2 databases as 2 schemas in the same database then you can create the foreign keys without any problem.



*: there's also another restriction: a permanent table cannot reference a temporary table.