The c77_dep
extension provides a comprehensive suite of tools for analyzing, visualizing, and managing database object dependencies in PostgreSQL databases. It helps database administrators and developers understand complex dependency relationships between tables, views, materialized views, and foreign tables.
Managing dependencies in complex PostgreSQL databases can be challenging. When making schema changes, it's crucial to understand how objects are interconnected to prevent breaking changes. This extension provides views and functions to map these relationships and make informed decisions during database maintenance, migrations, and refactoring.
Core views that analyze and expose database object dependencies
Tools to predict the impact of dropping objects or changing schemas
Identification of problematic circular dependencies
Scoring of objects based on their dependency characteristics
Functions to help determine the correct order for migrations
Export dependency graphs in DOT format for Graphviz visualization
Generate comprehensive dependency analysis reports
SELECT * FROM c77_dep_orphaned_objects
WHERE relation LIKE 'myschema.%';
SELECT * FROM c77_dep_analyze_drop_impact('myschema.mytable');
SELECT c77_dep_export_dependency_graph('myschema');
Save the output to a file with a .dot
extension and visualize it with Graphviz:
dot -Tpng dependencies.dot -o dependencies.png
SELECT c77_dep_generate_report();
SELECT * FROM c77_dep_detect_circular_dependencies();
SELECT * FROM c77_dep_generate_migration_order()
WHERE objects_to_migrate @> ARRAY['myschema.%'];
The extension can export dependency graphs in DOT format for visualization with Graphviz. Here's a workflow example:
-- Export dependency graph
\o dependencies.dot
SELECT c77_dep_export_dependency_graph('public', 3, true);
\o
-- Generate visualization (run in shell)
dot -Tpng dependencies.dot -o dependencies.png
dot -Tsvg dependencies.dot -o dependencies.svg
This creates visual dependency maps that help you understand complex relationships at a glance.
The dependency analysis can be resource-intensive on large databases. Consider:
Here's a typical workflow for planning database migrations:
-- 1. Generate comprehensive report
SELECT c77_dep_generate_report('public', true, true);
-- 2. Identify circular dependencies
SELECT * FROM c77_dep_detect_circular_dependencies();
-- 3. Assess risk for specific changes
SELECT * FROM c77_dep_risk_assessment WHERE relation LIKE '%target_table%';
-- 4. Plan migration order
SELECT * FROM c77_dep_generate_migration_order();
-- 5. Simulate schema changes
SELECT c77_dep_simulate_schema_change('old_schema', 'new_schema');
# Copy the extension files to your PostgreSQL extension directory
cp c77_dep.control c77_dep--1.0.0.sql /path/to/postgresql/share/extension/
# Connect to your database and create the extension
psql -d your_database
CREATE EXTENSION c77_dep;
Understand impact before making structural changes to avoid breaking dependent objects
Determine correct order for migrating objects between environments
Identify orphaned objects and cleanup candidates to reduce complexity
Evaluate risks before dropping or modifying database objects
Generate visual maps and reports for database architecture documentation
Track dependencies for regulatory requirements and change management
Smart dependency management for PostgreSQL!
This extension helps you make informed decisions about database changes by providing comprehensive dependency analysis and visualization tools.