legacy: --since-Delta für legacy:import + Importer setzen Timestamps wieder korrekt
--since=<Zeitpunkt> schränkt den Quell-Scan auf Legacy-Zeilen ein, deren created_at ODER updated_at im Fenster liegt (users/companies/contacts/ press-releases; Kategorien und link-associations bleiben ungefiltert). Kombiniert mit --force werden geänderte Bestandszeilen aktualisiert — damit dauert ein Tages-Delta Sekunden statt eines Volldurchlaufs über 150k+ Zeilen. Dazu Bugfix, der den Delta erst rund macht: User-/Company-/Contact- Importer übergaben created_at/updated_at innerhalb von updateOrCreate — die Felder sind nicht fillable und wurden stillschweigend verworfen (Live-Befund: NULL-Timestamps, bisher nur durch legacy:fix-timestamps geheilt). Jetzt explizit per forceFill wie im PressReleaseImporter. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
22b7bd38b7
commit
a0c2e663dc
8 changed files with 136 additions and 11 deletions
|
|
@ -8,6 +8,7 @@ use App\Models\User;
|
|||
use App\Services\Import\ImportContext;
|
||||
use App\Services\Import\PressReleaseImporter;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
|
@ -178,3 +179,64 @@ test('a force re-import preserves the uuid and the publication date', function (
|
|||
expect($second->uuid)->toBe($originalUuid);
|
||||
expect($second->published_at?->format('Y-m-d H:i:s'))->toBe('2009-04-08 15:43:42');
|
||||
});
|
||||
|
||||
test('a since delta only scans legacy rows created or updated in the window', function () {
|
||||
/** @var TestCase $this */
|
||||
seedLegacyPressReleaseSchema();
|
||||
|
||||
DB::connection('mysql_presseecho')->table('press_release')->insert([
|
||||
[
|
||||
'id' => 20,
|
||||
'title' => 'Alte unveränderte Meldung',
|
||||
'language' => 'de',
|
||||
'text' => 'Inhalt',
|
||||
'category_id' => 500,
|
||||
'user_id' => 700,
|
||||
'status' => 'published',
|
||||
'no_export' => false,
|
||||
'created_at' => '2019-05-01 08:00:00',
|
||||
'updated_at' => '2019-05-01 08:00:00',
|
||||
'slug' => 'alt-unveraendert',
|
||||
],
|
||||
[
|
||||
'id' => 21,
|
||||
'title' => 'Heute neu angelegt',
|
||||
'language' => 'de',
|
||||
'text' => 'Inhalt',
|
||||
'category_id' => 500,
|
||||
'user_id' => 700,
|
||||
'status' => 'published',
|
||||
'no_export' => false,
|
||||
'created_at' => '2026-07-20 09:00:00',
|
||||
'updated_at' => '2026-07-20 09:00:00',
|
||||
'slug' => 'heute-neu',
|
||||
],
|
||||
[
|
||||
'id' => 22,
|
||||
'title' => 'Alt, aber heute geändert',
|
||||
'language' => 'de',
|
||||
'text' => 'Inhalt',
|
||||
'category_id' => 500,
|
||||
'user_id' => 700,
|
||||
'status' => 'published',
|
||||
'no_export' => false,
|
||||
'created_at' => '2012-01-15 10:00:00',
|
||||
'updated_at' => '2026-07-20 10:30:00',
|
||||
'slug' => 'alt-heute-geaendert',
|
||||
],
|
||||
]);
|
||||
|
||||
app(PressReleaseImporter::class)->run(new ImportContext(
|
||||
'presseecho',
|
||||
false,
|
||||
true,
|
||||
Carbon::parse('2026-07-20 00:00:00'),
|
||||
));
|
||||
|
||||
$imported = PressRelease::withoutGlobalScopes()
|
||||
->where('legacy_portal', 'presseecho')
|
||||
->whereIn('legacy_id', [20, 21, 22])
|
||||
->pluck('legacy_id')->sort()->values()->all();
|
||||
|
||||
expect($imported)->toBe([21, 22]);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue