'How to restore a partitioned PostgreSQL database without partitions?

I have a partitioned Postgres database like:

  • items - partitioned table
  • items_2022 - partition for 2022 data
  • items_2021 - partition for 2021 data

I would like to dump this database and then restore it on a new server without partitions, meaning I would like all data to simply be an items table that is not partitioned. Is there a way to do this using pg_dump and restore?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source