From 880fa1699e8777b81ba0d87b72c182732ddb8187 Mon Sep 17 00:00:00 2001 From: Stephanya Casanova Date: Thu, 17 Oct 2024 14:56:07 +0200 Subject: [PATCH 1/2] [backend] Add index for expectations on inject --- ..._Add_indexes_scenario_exercise_latency.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 openbas-api/src/main/java/io/openbas/migration/V3_45__Add_indexes_scenario_exercise_latency.java diff --git a/openbas-api/src/main/java/io/openbas/migration/V3_45__Add_indexes_scenario_exercise_latency.java b/openbas-api/src/main/java/io/openbas/migration/V3_45__Add_indexes_scenario_exercise_latency.java new file mode 100644 index 0000000000..2821553dd2 --- /dev/null +++ b/openbas-api/src/main/java/io/openbas/migration/V3_45__Add_indexes_scenario_exercise_latency.java @@ -0,0 +1,18 @@ +package io.openbas.migration; + +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.springframework.stereotype.Component; + +import java.sql.Connection; +import java.sql.Statement; + +@Component +public class V3_45__Add_indexes_scenario_exercise_latency extends BaseJavaMigration { + @Override + public void migrate(Context context) throws Exception { + Connection connection = context.getConnection(); + Statement select = connection.createStatement(); + select.execute("CREATE INDEX IF NOT EXISTS idx_inject_expectation_inject_id ON injects_expectations(inject_id);"); + } +} From cce83f83cd3a947050aaf7ef131a9ef18ea0700d Mon Sep 17 00:00:00 2001 From: Stephanya Casanova Date: Thu, 17 Oct 2024 15:04:21 +0200 Subject: [PATCH 2/2] [backend] Add index for expectations on inject --- .../V3_45__Add_indexes_scenario_exercise_latency.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openbas-api/src/main/java/io/openbas/migration/V3_45__Add_indexes_scenario_exercise_latency.java b/openbas-api/src/main/java/io/openbas/migration/V3_45__Add_indexes_scenario_exercise_latency.java index 2821553dd2..5fd7f0619d 100644 --- a/openbas-api/src/main/java/io/openbas/migration/V3_45__Add_indexes_scenario_exercise_latency.java +++ b/openbas-api/src/main/java/io/openbas/migration/V3_45__Add_indexes_scenario_exercise_latency.java @@ -14,5 +14,10 @@ public void migrate(Context context) throws Exception { Connection connection = context.getConnection(); Statement select = connection.createStatement(); select.execute("CREATE INDEX IF NOT EXISTS idx_inject_expectation_inject_id ON injects_expectations(inject_id);"); + select.execute("CREATE INDEX IF NOT EXISTS idx_inject_expectation_team_id ON injects_expectations(team_id);"); + select.execute("CREATE INDEX IF NOT EXISTS idx_inject_expectation_user_id ON injects_expectations(user_id);"); + select.execute("CREATE INDEX IF NOT EXISTS idx_inject_expectation_asset_group_id ON injects_expectations(asset_group_id);"); + select.execute("CREATE INDEX IF NOT EXISTS idx_inject_expectation_asset_id ON injects_expectations(asset_id);"); + select.execute("CREATE INDEX IF NOT EXISTS idx_inject_expectation_exercise_id ON injects_expectations(exercise_id);"); } }