PHPackages                             aldoggutierrez/laravel-schema-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. aldoggutierrez/laravel-schema-manager

ActiveLibrary[Database &amp; ORM](/categories/database)

aldoggutierrez/laravel-schema-manager
=====================================

Manage PostgreSQL schemas in Laravel applications

v1.6.0(1mo ago)01.1k↑352.9%[2 PRs](https://github.com/Aldoggutierrez/laravel-schema-manager/pulls)MITPHPPHP ^8.2CI passing

Since Feb 13Pushed 1mo agoCompare

[ Source](https://github.com/Aldoggutierrez/laravel-schema-manager)[ Packagist](https://packagist.org/packages/aldoggutierrez/laravel-schema-manager)[ Docs](https://github.com/55823142-aldoggutierrez/laravel-schema-manager)[ GitHub Sponsors](https://github.com/Aldoggutierrez)[ RSS](/packages/aldoggutierrez-laravel-schema-manager/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (24)Versions (12)Used By (0)

Laravel Schema Manager
======================

[](#laravel-schema-manager)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4ba369547daecad6669ba9b0f6acb8ac7377fc692a6d31b0604c6efb6aad9568/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c646f6767757469657272657a2f6c61726176656c2d736368656d612d6d616e616765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aldoggutierrez/laravel-schema-manager)[![GitHub Tests Action Status](https://camo.githubusercontent.com/319d7a36096ed6cafd1b84658efaaab2de89b9baf25a0efdb0bef0d0b1cdd16e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c646f6767757469657272657a2f6c61726176656c2d736368656d612d6d616e616765722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/aldoggutierrez/laravel-schema-manager/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/ba3f7b3358ea10c24240b94235e35514a9787878b80d3ddb7477b4dbd29ef27d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c646f6767757469657272657a2f6c61726176656c2d736368656d612d6d616e616765722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/aldoggutierrez/laravel-schema-manager/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/5afbc6e4d5ba9fda03749ec2081c3175797925c4b3e323bfae23b73eb351581c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c646f6767757469657272657a2f6c61726176656c2d736368656d612d6d616e616765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aldoggutierrez/laravel-schema-manager)

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
------------

[](#installation)

You can install the package via composer:

```
composer require aldoggutierrez/laravel-schema-manager
```

Configuration
-------------

[](#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
-----

[](#usage)

### Move a table between schemas

[](#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-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

[](#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

[](#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_dump` to 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**

OptionDefaultDescription`--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 dumpThe command writes two sections to the output file:

1. Schema-only DDL (`pg_dump --schema-only`) for all requested schemas.
2. Data rows from the `migrations` table so Laravel knows which migrations have already been run.

Features
--------

[](#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
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Aldoggutierrez](https://github.com/55823142+Aldoggutierrez)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance89

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Recently: every ~21 days

Total

7

Last Release

54d ago

PHP version history (2 changes)v1.0.0PHP ^8.4

v1.2.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15272565?v=4)[aldogtz](/maintainers/aldogtz)[@Aldogtz](https://github.com/Aldogtz)

---

Top Contributors

[![Aldoggutierrez](https://avatars.githubusercontent.com/u/55823142?v=4)](https://github.com/Aldoggutierrez "Aldoggutierrez (26 commits)")

---

Tags

laravelschemamigrationdatabasepostgresql

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/aldoggutierrez-laravel-schema-manager/health.svg)

```
[![Health](https://phpackages.com/badges/aldoggutierrez-laravel-schema-manager/health.svg)](https://phpackages.com/packages/aldoggutierrez-laravel-schema-manager)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.9M11.7k](/packages/illuminate-database)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

213421.2k2](/packages/wnx-laravel-backup-restore)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17558.6k](/packages/lacodix-laravel-model-filter)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
