trogers1884 / dbdepends
A Laravel package that creates a view for PostgreSQL database dependencies
Requires
- php: ^8.1
- illuminate/database: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0
- phpunit/phpunit: ^10.0
README
A Laravel package that creates a PostgreSQL view for analyzing database dependencies in your project. This view helps you understand the relationships and dependencies between your database objects.
Requirements
- Laravel 10.0 or higher (including Laravel 11)
- PostgreSQL 12.0 or higher
- PHP 8.1 or higher
Installation
You can install the package via composer:
composer require trogers1884/dbdepends
After installation, run your migrations:
php artisan migrate
This will create a view named tr1884_v_dbdepends_dependency_map
in your PostgreSQL database.
Usage
Once installed, the view tr1884_v_dbdepends_dependency_map
will be available in your PostgreSQL database. The view provides information about dependencies between tables, views, and materialized views in your database.
View Columns
relation
: The fully qualified name of the database objectobject_type
: The type of object (TABLE, VIEW, MATV)owner
: The owner of the objectdeps
: Number of direct dependenciesadd_deps
: Number of indirect dependenciesreqs
: Number of direct requirementsadd_reqs
: Number of indirect requirementsdependents
: List of direct dependent objectsadd_dependents
: List of indirect dependent objectsrequirements
: List of direct required objectsadd_requirements
: List of indirect required objects
Uninstallation
To completely remove this package from your project:
- First, remove the view from your database:
php artisan migrate:rollback --path=vendor/trogers1884/dbdepends/src/database/migrations
- Remove the package from your composer.json:
composer remove trogers1884/dbdepends
- Remove the service provider from config/app.php if you manually added it:
// Remove this line if it exists Trogers1884\DBDepends\DBDependsServiceProvider::class,
- Clear your configuration cache:
php artisan config:clear
Development and Testing
Note: This section is for package developers only. If you're just using the package in your project, you can ignore these steps.
To set up a development environment for contributing to this package:
- Clone the repository
- Copy the package's phpunit configuration file:
cp phpunit.xml.dist phpunit.xml
- Update the database configuration in your
phpunit.xml
:
<php> <env name="DB_CONNECTION" value="pgsql"/> <env name="DB_HOST" value="127.0.0.1"/> <env name="DB_PORT" value="5432"/> <env name="DB_DATABASE" value="dbdepends_test"/> <env name="DB_USERNAME" value="your_username"/> <env name="DB_PASSWORD" value="your_password"/> </php>
- Create a PostgreSQL database for testing:
CREATE DATABASE dbdepends_test;
- Run the tests:
vendor/bin/phpunit
Disclaimer
This package is provided "as is" without warranty of any kind, either expressed or implied. The author is not responsible for any damages, data loss, or issues that may arise from using this package. It is the user's responsibility to:
- Properly back up their database before installing or using this package
- Test the package in a non-production environment first
- Ensure their database meets the minimum requirements
- Monitor and maintain their own database performance and security
- Verify the accuracy of dependency information provided by the view
This package simply provides a PostgreSQL view for analyzing SQL dependencies in your project. How you use this information and maintain your database is entirely your responsibility.
Contributing
Please see CONTRIBUTING.md for details.
Contributors
We appreciate all contributions, big and small! See CONTRIBUTORS.md for a full list of all contributors.
Credits
- Jeremy Gleed
- Tom Rogers
License
The MIT License (MIT). Please see License File for more information.