-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathV0_40_28_001__AddAttemptSyncConfig.java
39 lines (31 loc) · 1.28 KB
/
V0_40_28_001__AddAttemptSyncConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* Copyright (c) 2022 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.jooq.impl.SQLDataType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class V0_40_28_001__AddAttemptSyncConfig extends BaseJavaMigration {
private static final Logger LOGGER = LoggerFactory.getLogger(V0_40_28_001__AddAttemptSyncConfig.class);
@Override
public void migrate(final Context context) throws Exception {
LOGGER.info("Running migration: {}", this.getClass().getSimpleName());
// Warning: please do not use any jOOQ generated code to write a migration.
// As database schema changes, the generated jOOQ code can be deprecated. So
// old migration may not compile if there is any generated code.
try (final DSLContext ctx = DSL.using(context.getConnection())) {
addAttemptSyncConfigToAttempts(ctx);
}
}
private static void addAttemptSyncConfigToAttempts(final DSLContext ctx) {
ctx.alterTable("attempts")
.addColumnIfNotExists(DSL.field(
"attempt_sync_config",
SQLDataType.JSONB.nullable(true)))
.execute();
}
}