Port the Fuc 0.12.0 frontend and default-off VIP plugin. Include the previously approved password-reset token revocation. Deploy only to an independent FUC-XB test instance; no production cutover.
37 lines
2.7 KiB
PHP
37 lines
2.7 KiB
PHP
<?php
|
|
// Strictly local FUC instances only. Never invokes a production deployment.
|
|
umask(0077);
|
|
$root=dirname(__DIR__,2);$instance=$argv[1]??'';
|
|
if(!in_array($instance,['fuc-acceptance','fuc-migration-test'],true))throw new RuntimeException('Only the two marked local FUC instances are allowed');
|
|
$dir=$root.'/instances/'.$instance;
|
|
$marker=$instance==='fuc-acceptance'?'.fuc-acceptance':'.migration-rehearsal';
|
|
if(!is_file($dir.'/'.$marker))throw new RuntimeException('Missing local marker');
|
|
require $root.'/vendor/autoload.php';
|
|
$file=$dir.'/database/'.($instance==='fuc-acceptance'?'acceptance.sqlite':'rehearsal.sqlite');
|
|
$backup=$dir.'/storage/app/vip-before-install';
|
|
if(!is_dir($backup))mkdir($backup,0700,true);
|
|
if(!is_file($backup.'/database.sqlite')){
|
|
$source=new SQLite3($file,SQLITE3_OPEN_READONLY);$target=new SQLite3($backup.'/database.sqlite');
|
|
if(!$source->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;
|