backup($target))throw new RuntimeException('Backup failed');$source->close();$target->close(); } $app=require $instance==='fuc-acceptance'?$root.'/scripts/theme-fuc/integration-bootstrap.php':$root.'/codex/output/fuc-migration-20261103/rehearsal-bootstrap.php'; if(realpath(Illuminate\Support\Facades\DB::connection()->getDatabaseName())!==realpath($file))throw new RuntimeException('Wrong instance database'); $manager=app(App\Services\Plugin\PluginManager::class); if(!App\Models\Plugin::where('code','vip_loyalty')->exists())$manager->install('vip_loyalty'); $plugin=App\Models\Plugin::where('code','vip_loyalty')->firstOrFail(); $values=array_replace(Plugin\VipLoyalty\Settings::DEFAULTS,json_decode($plugin->config,true)?:[],['enabled'=>true]); $values=app(Plugin\VipLoyalty\Settings::class)->validate($values); $plugin->config=json_encode($values);$plugin->save();$manager->enable('vip_loyalty'); $count=0; if($instance==='fuc-migration-test') { $private=$root.'/codex/output/fuc-migration-20261103/private';$identities=[]; foreach(file($private.'/user-projection.jsonl',FILE_IGNORE_NEW_LINES) as $line){$v=json_decode($line,true,512,JSON_THROW_ON_ERROR);$identities[$v['legacy_id']]=$v['uuid'];} Illuminate\Support\Facades\DB::transaction(function()use($private,$identities,&$count){ $f=fopen($private.'/vip-opening.jsonl','r'); try{while(($line=fgets($f))!==false){$v=json_decode($line,true,512,JSON_THROW_ON_ERROR); app(Plugin\VipLoyalty\Service::class)->opening($v['user_id'],$identities[$v['user_id']],$v['opening_cumulative_cents'],'18f8346061922da82075f3d1d040f51247f23432b26e29ea2bfe73d8b7117103');++$count; }}finally{fclose($f);} }); } echo json_encode(['instance'=>$instance,'vip_enabled'=>app(Plugin\VipLoyalty\Service::class)->enabled(),'opening_users_checked'=>$count,'other_instances_written'=>0,'production_operations'=>0]).PHP_EOL;