|
@@ -4,24 +4,18 @@ use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
-use App\Models\Status;
|
|
|
|
|
|
|
|
return new class extends Migration
|
|
return new class extends Migration
|
|
{
|
|
{
|
|
public function up(): void
|
|
public function up(): void
|
|
{
|
|
{
|
|
- 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();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ DB::table('statuses')
|
|
|
|
+ ->join('profiles', 'profiles.id', '=', 'statuses.profile_id')
|
|
|
|
+ ->leftJoin('users', 'users.id', '=', 'profiles.user_id')
|
|
|
|
+ ->where('statuses.local', true)
|
|
|
|
+ ->where('statuses.type', 'share')
|
|
|
|
+ ->whereNull('users.id')
|
|
|
|
+ ->update(['statuses.local' => false]);
|
|
}
|
|
}
|
|
|
|
|
|
public function down(): void
|
|
public function down(): void
|