storefronts:import-legacy: add --deactivate-source for single source of truth
Deploy Ladill Merchant / deploy (push) Successful in 53s

After importing, optionally mark the platform copy inactive so Merchant
is the sole live owner and the platform stops double-counting. Public
scans still forward here (the monolith's MerchantQrForwarder routes
shop/menu by type regardless of is_active).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
isaacclad
2026-06-10 17:13:37 +00:00
co-authored by Claude Opus 4.8
parent 37425f5ad1
commit 9a6fdbd2ae
@@ -28,6 +28,7 @@ class ImportLegacyStorefronts extends Command
{--user= : Only import for this owner (platform public_id or email)}
{--refresh : Overwrite local codes that already exist (matched by short_code)}
{--skip-images : Do not copy image files, only the database rows}
{--deactivate-source : After a successful import, mark the platform copy inactive so Merchant is the single source of truth (public scans still forward here via type)}
{--dry-run : Report what would happen without writing anything}';
protected $description = 'Import legacy menu/shop storefronts and their products from the platform database.';
@@ -40,6 +41,7 @@ class ImportLegacyStorefronts extends Command
$dry = (bool) $this->option('dry-run');
$refresh = (bool) $this->option('refresh');
$skipImages = (bool) $this->option('skip-images');
$deactivateSource = (bool) $this->option('deactivate-source');
$platform = DB::connection('platform');
@@ -76,6 +78,7 @@ class ImportLegacyStorefronts extends Command
$skipped = 0;
$usersCreated = 0;
$imagesCopied = 0;
$deactivated = 0;
$failed = 0;
foreach ($rows as $row) {
@@ -165,10 +168,15 @@ class ImportLegacyStorefronts extends Command
if (! $skipImages) {
$imagesCopied += $this->copyImages($row->png_path, $row->svg_path, $row->payload);
}
if ($deactivateSource && $row->is_active) {
$platform->table('qr_codes')->where('id', $row->id)->update(['is_active' => 0]);
$deactivated++;
}
}
$this->newLine();
$this->info("Imported: {$imported} · Skipped: {$skipped} · Local users created: {$usersCreated} · Images copied: {$imagesCopied} · Failed: {$failed}");
$this->info("Imported: {$imported} · Skipped: {$skipped} · Local users created: {$usersCreated} · Images copied: {$imagesCopied} · Source deactivated: {$deactivated} · Failed: {$failed}");
if ($dry) {
$this->comment('Dry run — no changes were written.');