trait DatabaseTruncation (View source)

Traits

Properties

static protected array $allTables

The cached names of the database tables for each connection.

Methods

array
migrateFreshUsing()

The parameters that should be used when running "migrate:fresh".

bool
shouldDropViews()

Determine if views should be dropped when refreshing the database.

bool
shouldDropTypes()

Determine if types should be dropped when refreshing the database.

bool
shouldSeed()

Determine if the seed task should be run when refreshing the database.

mixed
seeder()

Determine the specific seeder class that should be used when refreshing the database.

void
truncateDatabaseTables()

Truncate the database tables for all configured connections.

void
truncateTablesForAllConnections()

Truncate the database tables for all configured connections.

void
truncateTablesForConnection(ConnectionInterface $connection, string|null $name)

Truncate the database tables for the given database connection.

array
getAllTablesForConnection(ConnectionInterface $connection, string|null $name)

Get all the tables that belong to the connection.

bool
tableExistsIn(array $table, array $tables)

Determine if a table exists in the given list, with or without its schema.

array
connectionsToTruncate()

The database connections that should have their tables truncated.

array|null
tablesToTruncate(ConnectionInterface $connection, string|null $connectionName)

Get the tables that should be truncated.

array
exceptTables(ConnectionInterface $connection, string|null $connectionName)

Get the tables that should not be truncated.

void
beforeTruncatingDatabase()

Perform any work that should take place before the database has started truncating.

void
afterTruncatingDatabase()

Perform any work that should take place once the database has finished truncating.

Details

protected array migrateFreshUsing()

The parameters that should be used when running "migrate:fresh".

Return Value

array

protected bool shouldDropViews()

Determine if views should be dropped when refreshing the database.

Return Value

bool

protected bool shouldDropTypes()

Determine if types should be dropped when refreshing the database.

Return Value

bool

protected bool shouldSeed()

Determine if the seed task should be run when refreshing the database.

Return Value

bool

protected mixed seeder()

Determine the specific seeder class that should be used when refreshing the database.

Return Value

mixed

protected void truncateDatabaseTables()

Truncate the database tables for all configured connections.

Return Value

void

protected void truncateTablesForAllConnections()

Truncate the database tables for all configured connections.

Return Value

void

protected void truncateTablesForConnection(ConnectionInterface $connection, string|null $name)

Truncate the database tables for the given database connection.

Parameters

ConnectionInterface $connection
string|null $name

Return Value

void

protected array getAllTablesForConnection(ConnectionInterface $connection, string|null $name)

Get all the tables that belong to the connection.

Parameters

ConnectionInterface $connection
string|null $name

Return Value

array

protected bool tableExistsIn(array $table, array $tables)

Determine if a table exists in the given list, with or without its schema.

Parameters

array $table
array $tables

Return Value

bool

protected array connectionsToTruncate()

The database connections that should have their tables truncated.

Return Value

array

protected array|null tablesToTruncate(ConnectionInterface $connection, string|null $connectionName)

Get the tables that should be truncated.

Parameters

ConnectionInterface $connection
string|null $connectionName

Return Value

array|null

protected array exceptTables(ConnectionInterface $connection, string|null $connectionName)

Get the tables that should not be truncated.

Parameters

ConnectionInterface $connection
string|null $connectionName

Return Value

array

protected void beforeTruncatingDatabase()

Perform any work that should take place before the database has started truncating.

Return Value

void

protected void afterTruncatingDatabase()

Perform any work that should take place once the database has finished truncating.

Return Value

void