mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-08 15:54:51 +00:00
Add migration
This commit is contained in:
parent
bcf99d637f
commit
f81a8be6db
1 changed files with 56 additions and 0 deletions
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use App\Profile;
|
||||
use App\ModLog;
|
||||
use App\Models\ModeratedProfile;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('moderated_profiles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('profile_url')->unique()->nullable()->index();
|
||||
$table->unsignedBigInteger('profile_id')->unique()->nullable();
|
||||
$table->string('domain')->nullable();
|
||||
$table->text('note')->nullable();
|
||||
$table->boolean('is_banned')->default(false);
|
||||
$table->boolean('is_nsfw')->default(false);
|
||||
$table->boolean('is_unlisted')->default(false);
|
||||
$table->boolean('is_noautolink')->default(false);
|
||||
$table->boolean('is_nodms')->default(false);
|
||||
$table->boolean('is_notrending')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$logs = ModLog::whereObjectType('App\Profile::class')->whereAction('admin.user.delete')->get();
|
||||
|
||||
foreach($logs as $log) {
|
||||
$profile = Profile::withTrashed()->find($log->object_id);
|
||||
if(!$profile || $profile->private_key) {
|
||||
continue;
|
||||
}
|
||||
ModeratedProfile::updateOrCreate([
|
||||
'profile_url' => $profile->remote_url,
|
||||
'profile_id' => $profile->id,
|
||||
], [
|
||||
'is_banned' => true,
|
||||
'domain' => $profile->domain,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('moderated_profiles');
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue