diff --git a/src/database/migrations/2026_05_28_000000_add_performance_indexes.php b/src/database/migrations/2026_05_28_000000_add_performance_indexes.php new file mode 100644 index 00000000..e3d3f621 --- /dev/null +++ b/src/database/migrations/2026_05_28_000000_add_performance_indexes.php @@ -0,0 +1,60 @@ +index('stationid', 'rainfall_stationid_index'); + $table->index('timestamp', 'rainfall_timestamp_index'); + $table->index(['stationid', 'timestamp'], 'rainfall_stationid_timestamp_index'); + }); + + Schema::table('waterlevel', function (Blueprint $table) { + $table->index('stationid', 'waterlevel_stationid_index'); + $table->index('datetime', 'waterlevel_datetime_index'); + $table->index(['stationid', 'datetime'], 'waterlevel_stationid_datetime_index'); + }); + + Schema::table('notification', function (Blueprint $table) { + $table->index('stationid', 'notification_stationid_index'); + $table->index('timestamp', 'notification_timestamp_index'); + $table->index('stationtype', 'notification_stationtype_index'); + }); + + Schema::table('siren', function (Blueprint $table) { + $table->index('stationid', 'siren_stationid_index'); + $table->index('active_time', 'siren_active_time_index'); + }); + } + + public function down(): void + { + Schema::table('rainfall', function (Blueprint $table) { + $table->dropIndex('rainfall_stationid_timestamp_index'); + $table->dropIndex('rainfall_timestamp_index'); + $table->dropIndex('rainfall_stationid_index'); + }); + + Schema::table('waterlevel', function (Blueprint $table) { + $table->dropIndex('waterlevel_stationid_datetime_index'); + $table->dropIndex('waterlevel_datetime_index'); + $table->dropIndex('waterlevel_stationid_index'); + }); + + Schema::table('notification', function (Blueprint $table) { + $table->dropIndex('notification_stationtype_index'); + $table->dropIndex('notification_timestamp_index'); + $table->dropIndex('notification_stationid_index'); + }); + + Schema::table('siren', function (Blueprint $table) { + $table->dropIndex('siren_active_time_index'); + $table->dropIndex('siren_stationid_index'); + }); + } +};