db(); $namespace = 'STAGE8_'.strtoupper(bin2hex(random_bytes(6))); $connection = 'db2_release_test'; $previous = DB::getDefaultConnection(); $admin->statement('CREATE SCHEMA '.$namespace); try { config(['database.connections.'.$connection => array_replace( config('database.connections.db2_local'), ['schema' => $namespace] )]); DB::setDefaultConnection($connection); $this->artisan('migrate', ['--database' => $connection, '--force' => true])->assertSuccessful(); $db = DB::connection($connection); $schema = $db->getSchemaBuilder(); $this->assertTrue($schema->hasColumn('users', 'two_factor_confirmed_at')); $user = User::factory()->create(); $db->table('passkeys')->insert([ 'user_id' => $user->getKey(), 'name' => 'Phase 8 passkey', 'credential_id' => 'phase8-fixture', 'credential' => '{}', 'created_at' => '2026-11-11 08:47:26.123456', 'last_used_at' => '2026-11-11 09:47:26.654321', ]); $this->actingAs($user) ->withSession(['auth.password_confirmed_at' => time()]) ->get(route('security.edit')) ->assertOk() ->assertSee('Phase 8 passkey'); $columns = array_column($schema->getColumns('failed_jobs'), null, 'name'); $this->assertStringContainsString('CURRENT', strtoupper((string) $columns['failed_at']['default'])); $this->artisan('migrate:rollback', ['--database' => $connection, '--force' => true])->assertSuccessful(); $this->assertSame(['migrations'], array_column($schema->getTables(), 'name')); $this->assertSame(0, (int) $db->table('migrations')->count()); } finally { DB::setDefaultConnection($previous); DB::purge($connection); $schema = $admin->getSchemaBuilder(); foreach ($schema->getTables($namespace) as $table) { $admin->statement('DROP TABLE '.$table['schema_qualified_name']); } $admin->statement('DROP SCHEMA '.$namespace.' RESTRICT'); } } }