#1024·pgroll

Versioned-schema views can block pg_partman retention drops on partition child tables

Author: javiercbkCreated Mar 9, 2026Updated Mar 11, 2026
Labelssql2pgroll

DISCLAIMER: This issue text was generated with AI assistance, but the behavior described here was observed in a real production-like environment.

Summary

We are seeing pg_partman maintenance fail when it tries to drop old partition child tables.

The failure is caused by a dependency from a pgroll-generated view in a versioned schema (for example, public_0005_migration_name) to a specific partition child table (for example, public.partitioned_table_20260101).

As a result, DROP TABLE in pg_partman retention fails and maintenance aborts.

What we expected

Running pgroll + pg_partman together should not leave versioned-schema objects that block partition lifecycle operations (DROP TABLE of old partitions) once retention is due.

What happens instead

CALL partitions.run_maintenance_proc(p_analyze => true) fails when retention tries to drop an old partition.

Error returned

could not get rows values: ERROR: cannot drop table partitioned_table_20260101 because other objects depend on it
CONTEXT: SQL statement "DROP TABLE public.partitioned_table_20260101"
PL/pgSQL function drop_partition_time(text,interval,boolean,boolean,text,timestamp with time zone) line 250 at EXECUTE
PL/pgSQL function partitions.run_maintenance(text,boolean,boolean) line 494 at assignment
SQL statement "SELECT partitions.run_maintenance('public.partitioned_table', p_jobmon := 't', p_analyze := 't')"
PL/pgSQL function partitions.run_maintenance_proc(integer,boolean,boolean) line 96 at EXECUTE
DETAIL: view public_0005_migration_name.partitioned_table_20260101 depends on table partitioned_table_20260101
HINT: Use DROP ... CASCADE to drop the dependent objects too.
SQLSTATE: P0001

Important context

  • The migration file itself does not explicitly create this view.
  • The dependent object appears to be an internal pgroll compatibility view in a versioned schema.
  • In pgroll docs, this aligns with the model where versioned schemas expose views over underlying tables during migration phases.
  • The migration was properly completed and was not left in a transient state

Why this is problematic

  • Partition retention via pg_partman is expected to drop old child tables.
  • A dependency from a versioned-schema view to a specific partition child table prevents this.
  • Maintenance job aborts entirely, causing operational issues and retention drift.

Reproduction outline

  1. Create/manage a partitioned table with pg_partman (retention_keep_table = false, retention window configured).
  2. Apply a pgroll migration that creates a versioned schema (for example migration 0005_migration_name).
  3. Let pg_partman retention attempt to drop an old partition child table.
  4. Observe DROP TABLE failure due to dependency from public_<migration>.<partition_child_name> view.

FINAL NOTE

I'm not sure this is a bug, maybe pgroll is never intended to work alongside pg_partman and that is fine, but I wanted to create this issue so that developers are aware of this short-circuit between pgroll and pg_partman and take the necessary precautions for this to not happen.