PHPackages                             endeavour-agency/refresh-database-on-demand - 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. endeavour-agency/refresh-database-on-demand

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

endeavour-agency/refresh-database-on-demand
===========================================

This packages offers a drop-in replacement for Laravel's RefreshDatabase trait, which only refreshes the database when migrations have actually changed.

1.0.0(1y ago)12.3k↓25%MITPHPPHP ^8.2

Since Nov 19Pushed 1y ago2 watchersCompare

[ Source](https://github.com/endeavour-agency/refresh-database-on-demand)[ Packagist](https://packagist.org/packages/endeavour-agency/refresh-database-on-demand)[ Docs](https://github.com/endeavour-agency/refresh-database-on-demand)[ RSS](/packages/endeavour-agency-refresh-database-on-demand/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Refresh Database On Demand
==========================

[](#refresh-database-on-demand)

This package offers a drop-in replacement for Laravel's [RefreshDatabase](https://laravel.com/docs/11.x/database-testing#resetting-the-database-after-each-test) trait.

Laravel's default `RefreshDatabase` trait always performs a `migrate:fresh` at the start of running a single or multiple tests, even when migrations haven't been added or deleted.

When using this package's `RefreshDatabaseOnDemand` trait instead, `migrate:fresh` will only be called when new migrations have been added or migrations have been deleted. This significantly reduces start-up time of running a single or a set of tests.

Installation
------------

[](#installation)

To install the package, simply require it with composer:

```
composer require endeavour-agency/refresh-database-on-demand
```

Usage
-----

[](#usage)

To start using the power of on-demand database refreshing, replace any occurrence of `Illuminate\Foundation\Testing\RefreshDatabase` with `EndeavourAgency\RefreshDatabaseOnDemand\Traits\RefreshDatabaseOnDemand`.

**Before:**

```
