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:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\SettingsRuntimeCanEditSync;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SyncRuntimeSettingsCanEditCommand extends Command
|
||||
{
|
||||
protected $signature = 'settings:sync-runtime-can-edit
|
||||
{database? : نام دیتابیس (پیشفرض DB_DATABASE)}';
|
||||
|
||||
protected $description = 'تثبیت can_edit=1 برای کلیدهای runtime tenant (Montzar، up/down_price، …)';
|
||||
|
||||
public function handle(SettingsRuntimeCanEditSync $sync): int
|
||||
{
|
||||
$database = trim((string) ($this->argument('database') ?: config('database.connections.'.config('database.default').'.database', '')));
|
||||
if ($database === '') {
|
||||
$this->error('DB_DATABASE خالی است یا database را بدهید.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$sync->useDatabase($database);
|
||||
$updated = $sync->sync();
|
||||
$this->info("DB {$database}: {$updated} row(s) updated");
|
||||
|
||||
foreach ($sync->statusMap() as $key => $canEdit) {
|
||||
$this->line(" {$key} => can_edit={$canEdit}");
|
||||
}
|
||||
|
||||
$violations = $sync->violations();
|
||||
if ($violations !== []) {
|
||||
$this->error('هنوز can_edit≠1: '.implode(', ', array_keys($violations)));
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$this->info('OK — همه کلیدهای runtime can_edit=1');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user