DatabaseMigrations
trait DatabaseMigrations
Traits
Provides per-worker database isolation for parallel testing.
Methods
The parameters that should be used when running "migrate:fresh".
Determine if views should be dropped when refreshing the database.
Determine if types should be dropped when refreshing the database.
Determine if the seed task should be run when refreshing the database.
Determine if database events should be dispatched while migrating the database.
Determine the specific seeder class that should be used when refreshing the database.
Rewrite the default connection's database name for parallel testing.
Ensure the per-worker database exists, creating it if needed.
Determine if the database should be managed for parallel testing.
Get the per-worker test database name.
Define hooks to migrate the database before and after each test.
Refresh a conventional test database.
Perform any work that should take place before the database has started refreshing.
Perform any work that should take place once the database has finished refreshing.
Details
in
CanConfigureMigrationCommands at line 18
protected array
migrateFreshUsing()
The parameters that should be used when running "migrate:fresh".
in
CanConfigureMigrationCommands at line 34
protected bool
shouldDropViews()
Determine if views should be dropped when refreshing the database.
in
CanConfigureMigrationCommands at line 42
protected bool
shouldDropTypes()
Determine if types should be dropped when refreshing the database.
in
CanConfigureMigrationCommands at line 50
protected bool
shouldSeed()
Determine if the seed task should be run when refreshing the database.
in
CanConfigureMigrationCommands at line 66
protected bool
shouldDispatchMigrationEvents()
Determine if database events should be dispatched while migrating the database.
in
CanConfigureMigrationCommands at line 86
protected mixed
seeder()
Determine the specific seeder class that should be used when refreshing the database.
in
InteractsWithParallelDatabase at line 43
protected void
configureParallelDatabaseName(mixed $app)
Rewrite the default connection's database name for parallel testing.
Config-only — does not create connections or purge pools. Called early in CreatesApplication (after config is loaded, before defineEnvironment) so that custom connections derived from the default connection inherit the per-worker database name.
No-op when not running in parallel or when using in-memory SQLite.
in
InteractsWithParallelDatabase at line 97
protected void
ensureParallelDatabaseExists()
Ensure the per-worker database exists, creating it if needed.
Called before Testbench database requirements and from database testing traits (RefreshDatabase, DatabaseMigrations, DatabaseTruncation, DatabaseTransactions) after the app is booted and connections are available. The config has already been rewritten by configureParallelDatabaseName().
No-op when not running in parallel or when using in-memory SQLite.
in
InteractsWithParallelDatabase at line 160
protected bool
shouldManageParallelDatabase(mixed $driver, string $database)
Determine if the database should be managed for parallel testing.
in
InteractsWithParallelDatabase at line 187
protected string
parallelTestDatabase(string $database, string $token)
Get the per-worker test database name.
at line 19
void
runDatabaseMigrations()
Define hooks to migrate the database before and after each test.
at line 37
protected void
refreshTestDatabase()
Refresh a conventional test database.
at line 47
protected void
beforeRefreshingDatabase()
Perform any work that should take place before the database has started refreshing.
at line 55
protected void
afterRefreshingDatabase()
Perform any work that should take place once the database has finished refreshing.