minor fixes

This commit is contained in:
2026-04-09 08:50:36 +02:00
parent 23d363a50c
commit a2457f4e49
75 changed files with 3848 additions and 387 deletions

View File

@@ -13,12 +13,14 @@ use Throwable;
*
* Usage:
* php artisan skinbase:import-legacy-artworks --chunk=500 --dry-run
* php artisan skinbase:import-legacy-artworks --artwork-id=69527
*/
class ImportLegacyArtworks extends Command
{
protected $signature = 'skinbase:import-legacy-artworks
{--chunk=500 : chunk size for processing}
{--limit= : maximum number of legacy rows to import}
{--artwork-id= : import only one legacy wallz row by id}
{--dry-run : do not persist any changes}
{--legacy-connection=legacy : name of legacy DB connection}
{--legacy-table=wallz : legacy artworks table name}
@@ -73,15 +75,28 @@ class ImportLegacyArtworks extends Command
{
$chunk = (int) $this->option('chunk');
$limit = $this->option('limit') ? (int) $this->option('limit') : null;
$artworkId = $this->option('artwork-id') ? (int) $this->option('artwork-id') : null;
$dryRun = (bool) $this->option('dry-run');
$legacyConn = $this->option('legacy-connection');
$legacyTable = $this->option('legacy-table');
$connectedTable = $this->option('connected-table');
if ($artworkId !== null && $artworkId <= 0) {
$this->error('The --artwork-id option must be a positive integer.');
return self::FAILURE;
}
$this->info("Starting import from {$legacyConn}.{$legacyTable} (chunk={$chunk})");
$query = DB::connection($legacyConn)->table($legacyTable)->orderBy('id');
if ($artworkId !== null) {
$this->info("Scoping import to legacy artwork id={$artworkId}");
$query->where('id', $artworkId);
$limit = 1;
}
$processed = 0;
$query->chunkById($chunk, function ($rows) use (&$processed, $limit, $dryRun, $legacyConn, $connectedTable) {
@@ -277,8 +292,14 @@ class ImportLegacyArtworks extends Command
return null;
}, 'id');
if ($artworkId !== null && $processed === 0) {
$this->warn("Legacy artwork id={$artworkId} was not found in {$legacyConn}.{$legacyTable}.");
return self::FAILURE;
}
$this->info('Import complete. Processed: ' . $processed);
return 0;
return self::SUCCESS;
}
}