24 lines
792 B
PHP
24 lines
792 B
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
final class IsolatedQaDatabase
|
|
{
|
|
public static function allowsSchemaChanges(): bool
|
|
{
|
|
$connection = config('database.connections.pgsql');
|
|
if (! app()->environment('testing') || config('database.default') !== 'pgsql'
|
|
|| ! in_array($connection['host'], ['127.0.0.1', 'localhost'], true)
|
|
|| (string) $connection['port'] !== '55441' || ! empty($connection['url'])
|
|
|| ! str_ends_with($connection['database'], '_test')) {
|
|
return false;
|
|
}
|
|
|
|
$identity = DB::selectOne('SELECT current_database() AS database, inet_server_port() AS port');
|
|
|
|
return $identity->database === $connection['database'] && (int) $identity->port === 55441;
|
|
}
|
|
}
|