dskripchenko / laravel-schemify
Schemify database manager for PostgreSQL — dynamic multi-schema "layer" connections with per-layer migrate / seed / wipe via a --layer option.
Requires
- php: ^8.2
- dskripchenko/laravel-api: ^5.0
- dskripchenko/php-array-helper: ^1.0
- laravel/framework: ^11.0 || ^12.0 || ^13.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0 || ^10.0 || ^11.0
- phpstan/phpstan: ^2.0
README
Dynamic multi-schema PostgreSQL connections for Laravel. Schemify models
each PostgreSQL schema as a layer (a layer_items row pointing at a
db_connections row) and adds a --layer option to Laravel's migrate,
db:seed and db:wipe commands so you can run them against any layer's schema
on the fly. Layers can live in the same database (different schemas) or in
entirely different databases.
Schemify is a lightweight schema/connection switcher wired into the migration commands — not a full tenancy framework. If you need automatic tenant identification, cache/queue/filesystem isolation or single-DB row scoping, reach for stancl/tenancy or spatie/laravel-multitenancy.
Supported versions
| Versions | |
|---|---|
| PHP | 8.2 · 8.3 · 8.4 · 8.5 |
| Laravel | 11 · 12 · 13 |
| Database | PostgreSQL |
Install
composer require dskripchenko/laravel-schemify php artisan layers:install
The provider is auto-discovered. layers:install publishes the config and core
migration, creates the db_connections / layer_items tables on the central
connection, and registers the default main layer.
Quick tour
php artisan layers:new acme --schema=acme --migrate # create a layer + schema, run tenant migrations php artisan migrate --layer=acme # migrate a single layer php artisan layers:list # list layers
use Dskripchenko\Schemify\Facades\Schemify; $total = Schemify::use('acme', fn () => Invoice::sum('amount'));
Documentation
Upgrading from 2.x? See UPGRADE.md and the CHANGELOG.
License
MIT © Denis Skripchenko