mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-02-23 22:50:46 +00:00
Refactor migration
This commit is contained in:
parent
d97383c0f6
commit
3109e6a1ab
1 changed files with 7 additions and 13 deletions
|
@ -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()
|
DB::table('statuses')
|
||||||
->where('local', true)
|
->join('profiles', 'profiles.id', '=', 'statuses.profile_id')
|
||||||
->where('type', 'share')
|
->leftJoin('users', 'users.id', '=', 'profiles.user_id')
|
||||||
->whereHas('profile', function($query) {
|
->where('statuses.local', true)
|
||||||
$query->whereDoesntHave('user');
|
->where('statuses.type', 'share')
|
||||||
})
|
->whereNull('users.id')
|
||||||
->chunkById(100, function($statuses) {
|
->update(['statuses.local' => false]);
|
||||||
foreach($statuses as $status) {
|
|
||||||
$status->local = false;
|
|
||||||
$status->save();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(): void
|
public function down(): void
|
||||||
|
|
Loading…
Reference in a new issue