fix(settings): PHP sync for runtime can_edit after deploy

Force can_edit=1 for Montzar/price runtime keys via settings:deploy
and settings:sync-runtime-can-edit, so tenant DB stays correct even
when an older deploy SQL is still on the server.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-19 21:07:12 +03:30
co-authored by Cursor
parent b7eed369c6
commit 924234bb19
6 changed files with 169 additions and 0 deletions
@@ -2,6 +2,7 @@
namespace App\Console\Commands;
use App\Services\SettingsRuntimeCanEditSync;
use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
@@ -100,6 +101,8 @@ class DeploySettingsConstCommand extends Command
return self::FAILURE;
}
$this->syncRuntimeCanEdit($db);
$this->info(" done: {$db}");
}
@@ -129,6 +132,38 @@ class DeploySettingsConstCommand extends Command
return $path;
}
private function syncRuntimeCanEdit(string $database): void
{
try {
$sync = app(SettingsRuntimeCanEditSync::class);
$sync->useDatabase($database);
$updated = $sync->sync();
$this->line(" runtime can_edit sync: {$updated} row(s) updated");
$status = $sync->statusMap();
if ($status !== []) {
$preview = collect($status)
->map(fn ($canEdit, $key) => "{$key}={$canEdit}")
->implode(', ');
$this->line(" runtime keys: {$preview}");
}
$violations = $sync->violations();
if ($violations !== []) {
$this->warn(' WARN: runtime keys still can_edit≠1: '.implode(', ', array_keys($violations)));
}
$fee = \App\Models\Setting::query()
->where('key', 'fee_deduct_from_gold')
->first(['key', 'can_edit']);
if ($fee) {
$this->line(" check fee_deduct_from_gold can_edit={$fee->can_edit}");
}
} catch (\Throwable $e) {
$this->warn(' runtime can_edit sync skipped: '.$e->getMessage());
}
}
private function findMysqlBinary(): ?string
{
$process = new Process(['command', '-v', 'mysql']);