PostgreSQL 11 foreign key on partitioning tables

PostgreSQL v12.0 will probably support foreign keys that reference partitioned tables. But this is still not guaranteed as v12.0 is still in development.

For v11 and lower versions, you may use triggers as described by depesz in these posts: part1, part2, and part3.

Update: PostgreSQL v12.0 was released on Oct 3, 2019, with this feature included


Postgres 11 only supports foreign keys from a partitioned table to a (non-partitioned) table.

Previously not even that was possible, and that's what the release notes are about.

This limitation is documented in the chapter about partitioning in the manual

While primary keys are supported on partitioned tables, foreign keys referencing partitioned tables are not supported. (Foreign key references from a partitioned table to some other table are supported.

(emphasis mine)