mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-22 13:03:16 +00:00
Add migration
This commit is contained in:
parent
dc6b9f4661
commit
86ac10fab7
1 changed files with 36 additions and 0 deletions
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('instances', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('instances');
|
||||
if (! array_key_exists('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||
$table->index('nodeinfo_last_fetched');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('instances', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('instances');
|
||||
if (array_key_exists('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||
$table->dropIndex('instances_nodeinfo_last_fetched_index');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue