NAME

DBIO::PostgreSQL::Diff::Dependents - A drop that meets objects outside the model is refused, naming them

VERSION

version 0.900007

SYNOPSIS

use DBIO::PostgreSQL::Diff::Dependents ();

# in the diff method of an operation class, before the drop is built
DBIO::PostgreSQL::Diff::Dependents->refuse(
  map { {
    object     => "table $_",
    dependents => $outside->{tables}{$_},
  } } @dropped,
);

DESCRIPTION

DBIO::PostgreSQL::Diff writes DROP TABLE, DROP TYPE and DROP SCHEMA without CASCADE. The order of the operations drops what the model holds in or on the object first (foreign keys, views, indexes, columns, tables, functions, types); what is left is what the model does not hold, and the server refuses the drop for it. With pg_schemas the model holds the declared schemas only, so a materialized view in another schema that reads the table, a foreign key of another schema's table that points at it, or a column of another schema's table that is of the type, is outside the model and stands in the way.

The rule that answers this stands here, once:

A drop that would meet an object outside the model is not written. The outside_dependents section of the model (DBIO::PostgreSQL::Introspect::OutsideDependents) names such objects, and "refuse" dies with refusing to diff: ..., see "WHAT IS REFUSED" in DBIO::PostgreSQL::Diff, naming each object and what depends on it. The message carries names only. Without the section (a model built by hand, or one read before it existed) nothing is checked, and RESTRICT is what stops the statement.

METHODS

refuse

DBIO::PostgreSQL::Diff::Dependents->refuse(
  { object => 'table app.orders', dependents => \@entries }, ...);

Each argument names an object the diff would drop (object, as the message says it: kind and name) and the entries of the outside_dependents section for it (kind, name and, for a foreign key, on). Returns when none has a dependent; otherwise dies with one message for all of them.

AUTHOR

DBIO & DBIx::Class Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.