diff --git a/database/migrations/2025_01_18_061532_fix_local_statuses.php b/database/migrations/2025_01_18_061532_fix_local_statuses.php index c1c5e8a21..f17eeaa0f 100644 --- a/database/migrations/2025_01_18_061532_fix_local_statuses.php +++ b/database/migrations/2025_01_18_061532_fix_local_statuses.php @@ -4,16 +4,24 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\DB; +use App\Models\Status; return new class extends Migration { public function up(): void { - DB::table('statuses') - ->leftJoin('profiles', 'statuses.profile_id', '=', 'profiles.id') - ->leftJoin('users', 'users.profile_id', '=', 'profiles.id') - ->whereNull('users.id') - ->update(['local' => false]); + Status::query() + ->where('local', true) + ->where('type', 'share') + ->whereHas('profile', function($query) { + $query->whereDoesntHave('user'); + }) + ->chunkById(100, function($statuses) { + foreach($statuses as $status) { + $status->local = false; + $status->save(); + } + }); } public function down(): void