Looking to hire Laravel developers? Try LaraJobs

laravel-refreshable-databases maintained by misakstvanu

Description
Adds refreshable database connections support to Laravel's migrate:fresh command
Author
misakstvanu
Last update
2026/07/23 12:38 (dev-master)
License
Links
Downloads
0

Comments
comments powered by Disqus

laravel-refreshable-databases

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 the database config, 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:

  1. Wipe all tables for every connection listed in database.refreshable.
  2. 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