'testing', 'APP_CONFIG_CACHE' => dirname(__DIR__).'/storage/framework/cache/local-qa-config.php'] as $key => $value) { putenv($key.'='.$value); $_ENV[$key] = $_SERVER[$key] = $value; } $app = require dirname(__DIR__).'/bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); $connection = config('database.connections.pgsql'); if (app()->configurationIsCached() || config('database.default') !== 'pgsql' || $connection['host'] !== '127.0.0.1' || (string) $connection['port'] !== '55441' || $connection['database'] !== 'investmoz_local_test' || ! empty($connection['url'])) { fwrite(STDERR, 'Refused: explicit isolated local QA database required.'.PHP_EOL); exit(1); } $identity = DB::selectOne('SELECT current_database() AS database, inet_server_port() AS port'); if ($identity->database !== 'investmoz_local_test' || (int) $identity->port !== 55441) { fwrite(STDERR, 'Refused: actual QA server identity differs.'.PHP_EOL); exit(1); } try { $status = Artisan::call('migrate', ['--force' => true]); } catch (Throwable $error) { fwrite(STDERR, 'Local QA migration failed: '.$error->getMessage().PHP_EOL); exit(1); } echo Artisan::output(); if ($status !== 0) { exit($status); } // Never reset an account or overwrite an existing demo on a repeated setup. if (DB::table('sectors')->count() === 0 && DB::table('users')->count() === 0) { $status = Artisan::call('db:seed', ['--force' => true]); echo Artisan::output(); exit($status); } echo 'Existing local demo preserved; seed skipped.'.PHP_EOL;