From f81a8be6db4240b0bc720f0a1f311a4d9c9fe997 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 15 Oct 2024 00:13:08 -0600 Subject: [PATCH] Add migration --- ...044935_create_moderated_profiles_table.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 database/migrations/2024_10_15_044935_create_moderated_profiles_table.php diff --git a/database/migrations/2024_10_15_044935_create_moderated_profiles_table.php b/database/migrations/2024_10_15_044935_create_moderated_profiles_table.php new file mode 100644 index 000000000..2aa9580a5 --- /dev/null +++ b/database/migrations/2024_10_15_044935_create_moderated_profiles_table.php @@ -0,0 +1,56 @@ +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'); + } +};