fix: Update MigrateNewsCommand to filter empty tags and make slug column nullable in tag migration
This commit is contained in:
parent
7d0e7c7121
commit
89b4793667
@ -46,7 +46,6 @@ public function handle()
|
||||
|
||||
// Get a default author ID (prefer Developer or Admin)
|
||||
$defaultAuthorId = DB::table('users')->first()?->id ?? 1;
|
||||
|
||||
$this->withProgressBar($legacyNews, function ($legacy) use ($defaultAuthorId) {
|
||||
// Use updateOrInsert for the basic record
|
||||
DB::table('news')->updateOrInsert(
|
||||
@ -73,7 +72,7 @@ public function handle()
|
||||
if ($news) {
|
||||
// split by comma or other delimiter if multiple tags,
|
||||
// legacy 'tag' column is varchar(20), likely a single tag or comma separated
|
||||
$tags = array_map('trim', explode(',', $legacy->tag));
|
||||
$tags = array_filter(array_map('trim', explode(',', $legacy->tag)));
|
||||
$news->syncTags($tags);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ public function up(): void
|
||||
$table->id();
|
||||
|
||||
$table->json('name');
|
||||
$table->json('slug');
|
||||
$table->json('slug')->nullable();
|
||||
$table->string('type')->nullable();
|
||||
$table->integer('order_column')->nullable();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user