Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add missing indexes to the oracle ddl script #503

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,25 @@ public static void clearTables(DataSource dataSource) {
}

public static Consumer<DataSource> runSqlResource(String resource) {
return runSqlResource(resource, false);
}

public static Consumer<DataSource> runSqlResource(String resource, boolean splitStatements) {
return dataSource -> {
final JdbcRunner jdbcRunner = new JdbcRunner(dataSource);
try {
final String statements =
CharStreams.toString(
new InputStreamReader(DbUtils.class.getResourceAsStream(resource)));
jdbcRunner.execute(statements, NOOP);
if (splitStatements) {
for (String statement : statements.split(";")) {
if (!statement.trim().isEmpty()) {
jdbcRunner.execute(statement, NOOP);
}
}
} else {
jdbcRunner.execute(statements, NOOP);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void initSchema() {
pooledDatasource = new HikariDataSource(hikariConfig);

// init schema
DbUtils.runSqlResource("/oracle_tables.sql").accept(pooledDatasource);
DbUtils.runSqlResource("/oracle_tables.sql", true).accept(pooledDatasource);
}

@BeforeEach
Expand Down
4 changes: 3 additions & 1 deletion db-scheduler/src/test/resources/oracle_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ create table scheduled_tasks
last_heartbeat TIMESTAMP(6) WITH TIME ZONE,
version NUMBER(19, 0),
PRIMARY KEY (task_name, task_instance)
)
);

CREATE INDEX scheduled_tasks__execution_time__idx on scheduled_tasks(execution_time);
CREATE INDEX scheduled_tasks__last_heartbeat__idx on scheduled_tasks(last_heartbeat);
Loading