From 86ac10fab72337ccf8f9faf4d57df8cc2e0dea18 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 31 May 2024 03:17:54 -0600 Subject: [PATCH] Add migration --- ..._add_index_to_nodeinfo_last_fetched_at.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 database/migrations/2024_05_31_090555_update_instances_table_add_index_to_nodeinfo_last_fetched_at.php 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'); + } + }); + } +};