Skip to content

Commit

Permalink
Add new indices on the jobs table (#11590)
Browse files Browse the repository at this point in the history
* Add new indices on the `jobs` table

* Format

* Fix build
  • Loading branch information
malikdiarra authored Mar 31, 2022
1 parent a203d68 commit 152af7c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void testBootloaderAppBlankDb() throws Exception {
container.getPassword(),
container.getJdbcUrl()).getInitialized();
val jobsMigrator = new JobsDatabaseMigrator(jobDatabase, this.getClass().getName());
assertEquals("0.35.40.001", jobsMigrator.getLatestMigration().getVersion().getVersion());
assertEquals("0.35.62.001", jobsMigrator.getLatestMigration().getVersion().getVersion());

val configDatabase = new ConfigsDatabaseInstance(
mockedConfigs.getConfigDatabaseUser(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2021 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.db.instance.jobs.migrations;

import org.flywaydb.core.api.migration.BaseJavaMigration;
import org.flywaydb.core.api.migration.Context;
import org.jooq.DSLContext;
import org.jooq.impl.DSL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class V0_35_62_001__AddJobIndices extends BaseJavaMigration {

private static final Logger LOGGER = LoggerFactory.getLogger(V0_35_62_001__AddJobIndices.class);

@Override
public void migrate(final Context context) throws Exception {
LOGGER.info("Running migration: {}", this.getClass().getSimpleName());

try (final DSLContext ctx = DSL.using(context.getConnection())) {
ctx.createIndexIfNotExists("jobs_config_type_idx").on("jobs", "config_type").execute();
ctx.createIndexIfNotExists("jobs_scope_idx").on("jobs", "scope").execute();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ create unique index "job_attempt_idx" on "public"."attempts"(
"job_id" asc,
"attempt_number" asc
);
create index "jobs_config_type_idx" on "public"."jobs"("config_type" asc);
create unique index "jobs_pkey" on "public"."jobs"("id" asc);
create index "jobs_scope_idx" on "public"."jobs"("scope" asc);

0 comments on commit 152af7c

Please sign in to comment.