2025_01_18_061532_fix_local_statuses.php 710 B

12345678910111213141516171819202122232425
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. use Illuminate\Support\Facades\DB;
  6. return new class extends Migration
  7. {
  8. public function up(): void
  9. {
  10. DB::table('statuses')
  11. ->join('profiles', 'profiles.id', '=', 'statuses.profile_id')
  12. ->leftJoin('users', 'users.id', '=', 'profiles.user_id')
  13. ->where('statuses.local', true)
  14. ->where('statuses.type', 'share')
  15. ->whereNull('users.id')
  16. ->update(['statuses.local' => false]);
  17. }
  18. public function down(): void
  19. {
  20. // No down migration needed since this is a data fix
  21. }
  22. };