aldoggutierrez/laravel-schema-manager
Composer 安装命令:
composer require aldoggutierrez/laravel-schema-manager
包简介
Manage PostgreSQL schemas in Laravel applications
README 文档
README
Manage PostgreSQL schemas in Laravel applications with ease. Move tables between schemas while preserving foreign keys and relationships. Generate versioned schema migrations and dump the full database schema to a SQL file.
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
Generate a schema migration
Creates a versioned migration file that moves a table between schemas using
ALTER TABLE … SET SCHEMA. The generated migration also handles any sequences
attached to the table.
# Specify schemas explicitly php artisan make:schema-migration orders --from=external --to=public # Omit options to be prompted interactively php artisan make:schema-migration orders
The generated file is placed in database/migrations/ with a timestamped name
such as 2024_01_01_120000_move_orders_from_external_to_public.php. It contains
both up() and down() methods so the move is fully reversible.
Dump the database schema
Exports the PostgreSQL schema (DDL) for one or more schemas to a SQL file using
pg_dump. Useful for keeping a schema snapshot in version control and for
seeding fresh environments without running every historical migration.
Requires
pg_dumpto be installed and accessible on$PATH.
# Dump the default pgsql connection (uses search_path, falls back to public) php artisan schema:dump # Specify a custom connection php artisan schema:dump --database=tenant # Dump specific schemas php artisan schema:dump --schemas=billing,reports # Write to a custom path php artisan schema:dump --path=/tmp/schema.sql # Prune existing migration files after dumping php artisan schema:dump --prune
Options
| Option | Default | Description |
|---|---|---|
--database |
pgsql |
Laravel database connection to use |
--schemas |
connection search_path or public |
Comma-separated list of schemas to dump |
--path |
database/schema/{connection}-schema.sql |
Output file path |
--prune |
— | Delete all files in database/migrations/ after the dump |
The command writes two sections to the output file:
- Schema-only DDL (
pg_dump --schema-only) for all requested schemas. - Data rows from the
migrationstable so Laravel knows which migrations have already been run.
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 ✅ Generate reversible schema migration files ✅ Dump the full schema (DDL + migrations data) to a SQL file
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.
aldoggutierrez/laravel-schema-manager 适用场景与选型建议
aldoggutierrez/laravel-schema-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.32k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「schema」 「postgresql」 「migration」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aldoggutierrez/laravel-schema-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aldoggutierrez/laravel-schema-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aldoggutierrez/laravel-schema-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
SilverStripe now has tentative support for PostgreSQL ('Postgres')
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
Extension for Opis JSON Schema
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
EAV modeling package for Eloquent and Laravel.
统计信息
- 总下载量: 1.32k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-13