aldoggutierrez / laravel-schema-manager
Manage PostgreSQL schemas in Laravel applications
Fund package maintenance!
Aldoggutierrez
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/aldoggutierrez/laravel-schema-manager
Requires
- php: ^8.4
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
README
Manage PostgreSQL schemas in Laravel applications with ease. Move tables between schemas while preserving foreign keys and relationships.
Installation
You can install the package via composer:
composer require aldoggutierrez/laravel-schema-manager
Configuration
Publish the configuration file:
php artisan vendor:publish --tag="schema-manager-config"
Available options in config/schema-manager.php:
return [ 'default_source_schema' => env('SCHEMA_MANAGER_SOURCE', 'external'), 'default_destination_schema' => env('SCHEMA_MANAGER_DESTINATION', 'public'), 'connection' => env('SCHEMA_MANAGER_CONNECTION', null), 'log_queries' => env('SCHEMA_MANAGER_LOG_QUERIES', false), ];
These are the contents of the published config file:
return [ /* * Default source schema when moving tables */ 'default_source_schema' => env('SCHEMA_MANAGER_SOURCE', 'external'), /* * Default destination schema when moving tables */ 'default_destination_schema' => env('SCHEMA_MANAGER_DESTINATION', 'public'), /* * Database connection to use (leave null to use default) */ 'connection' => env('SCHEMA_MANAGER_CONNECTION', null), /* * Enable query logging during operations */ 'log_queries' => env('SCHEMA_MANAGER_LOG_QUERIES', false), ];
Usage
Move a table between schemas
# Basic usage (uses config defaults) php artisan schema:move-table authorized_charges # Specify source and destination php artisan schema:move-table users --from=external --to=public # Preview changes without executing php artisan schema:move-table orders --dry-run # Skip confirmation prompt php artisan schema:move-table products --force
List tables in schemas
# List tables in default schema php artisan schema:list-tables # List tables in specific schema php artisan schema:list-tables external # List all schemas and their tables php artisan schema:list-tables --all
Features
✅ Move tables between PostgreSQL schemas
✅ Automatically handles foreign key constraints
✅ Preserves all relationships (ON UPDATE/DELETE rules)
✅ Cross-schema foreign key support
✅ Dry-run mode to preview changes
✅ Transaction-based for safety
✅ List tables and schemas
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.