misakstvanu / laravel-refreshable-databases
Adds refreshable database connections support to Laravel's migrate:fresh command
Package info
github.com/misakstvanu/laravel-refreshable-databases
pkg:composer/misakstvanu/laravel-refreshable-databases
Requires
- php: ^8.1
- illuminate/console: >=10.0
- illuminate/database: >=10.0
- illuminate/support: >=10.0
Requires (Dev)
- orchestra/testbench: >=8.0
- phpunit/phpunit: >=10.0
This package is auto-updated.
Last update: 2026-07-23 10:38:38 UTC
README
A Laravel package that lets you declare additional database connections that
should be wiped and re-migrated every time php artisan migrate:fresh runs.
Requirements
| Package | Version |
|---|---|
| PHP | ^8.1 |
| Laravel | 10, 11, or 12 |
Installation
composer require misakstvanu/laravel-refreshable-databases
The service provider is auto-discovered by Laravel — no manual registration is needed.
Configuration
Add a refreshable key to your config/database.php:
// config/database.php return [ // ... your existing connections ... /* |-------------------------------------------------------------------------- | Refreshable Connections |-------------------------------------------------------------------------- | | List the names of database connections that should also be wiped and | re-migrated every time `php artisan migrate:fresh` is executed. | */ 'refreshable' => [ 'secondary', 'reporting', ], ];
Note: The package automatically merges a default
refreshable: []into thedatabaseconfig, so you only need to add the key when you want to specify connections.
Usage
Simply run the standard Artisan command:
php artisan migrate:fresh
In addition to refreshing the default (or --database-specified) connection, the
command will also:
- Wipe all tables for every connection listed in
database.refreshable. - Run all migrations for each of those connections.
All options accepted by the built-in migrate:fresh command — --seed,
--seeder, --drop-views, --drop-types, --path, --realpath,
--schema-path, --step, --force — are forwarded to each refreshable
connection automatically.
How It Works
The package registers a custom FreshCommand (with the same migrate:fresh
signature) that extends Laravel's built-in command. After the standard fresh-
migration cycle completes, it iterates over config('database.refreshable') and
runs db:wipe followed by migrate for each listed connection.
Because Laravel loads package service providers after the core providers, the
package's command registration cleanly replaces the built-in migrate:fresh
command with no extra configuration needed.
Testing
composer test
License
MIT