diff --git a/database/migrations/2024_05_31_090555_update_instances_table_add_index_to_nodeinfo_last_fetched_at.php b/database/migrations/2024_05_31_090555_update_instances_table_add_index_to_nodeinfo_last_fetched_at.php new file mode 100644 index 000000000..cdd64cfec --- /dev/null +++ b/database/migrations/2024_05_31_090555_update_instances_table_add_index_to_nodeinfo_last_fetched_at.php @@ -0,0 +1,36 @@ +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'); + } + }); + } +};