Merge pull request #3951 from pixelfed/staging

Add migration
This commit is contained in:
daniel 2022-12-17 20:48:19 -07:00 committed by GitHub
commit 9533d77b07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 6 deletions

View file

@ -56,7 +56,8 @@ class MediaS3GarbageCollector extends Command
$limit = $this->option('limit'); $limit = $this->option('limit');
$minId = Media::orderByDesc('id')->where('created_at', '<', now()->subHours(12))->first()->id; $minId = Media::orderByDesc('id')->where('created_at', '<', now()->subHours(12))->first()->id;
$gc = Media::whereNotNull(['status_id', 'cdn_url', 'replicated_at']) $gc = Media::whereRemoteMedia(false)
->whereNotNull(['status_id', 'cdn_url', 'replicated_at'])
->whereNot('version', '4') ->whereNot('version', '4')
->where('id', '<', $minId) ->where('id', '<', $minId)
->inRandomOrder() ->inRandomOrder()

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('media', function (Blueprint $table) {
$table->index('remote_media');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('media', function (Blueprint $table) {
$table->dropIndex('media_remote_media_index');
});
}
};