Skip to content

Commit c633d60

Browse files
authored
Remove v0.30.0 file-based migration (#5984)
* Add warning in migration readme * Revert yaml file update * Remove resource files for v0.30.0 migration * Revert "Revert yaml file update" This reverts commit 4cc0905. * Remove v0.30.0 migration * Update unit test * Check for null
1 parent 4fa05b7 commit c633d60

File tree

19 files changed

+20
-532
lines changed

19 files changed

+20
-532
lines changed

airbyte-config/models/src/main/resources/types/Notification.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ description: Notification Settings
66
type: object
77
required:
88
- notificationType
9-
- sendOnSuccess
10-
- sendOnFailure
119
additionalProperties: false
1210
properties:
1311
# Instead of this type field, we would prefer a json schema "oneOf" but unfortunately,

airbyte-migration/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This module migrates configs specified in `airbyte-config` to new versions.
44

5+
WARNING: the file-based migrations are deprecated. Please write a Flyway migration whenever you want to update the database. See [here](../airbyte-db/lib/README.md) for details.
6+
57
## Change Airbyte Configs
68
- Update the config json schema in [`airbyte-config/models`](../airbyte-config/models).
79
- Add the changed json schema to the [main resources](./src/main/resources/migrations).

airbyte-migration/src/main/java/io/airbyte/migrate/Migrations.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import io.airbyte.migrate.migrations.MigrationV0_27_0;
3838
import io.airbyte.migrate.migrations.MigrationV0_28_0;
3939
import io.airbyte.migrate.migrations.MigrationV0_29_0;
40-
import io.airbyte.migrate.migrations.MigrationV0_30_0;
4140
import io.airbyte.migrate.migrations.NoOpMigration;
4241
import java.util.List;
4342

@@ -59,8 +58,7 @@ public class Migrations {
5958
private static final Migration MIGRATION_V_0_26_0 = new MigrationV0_26_0(MIGRATION_V_0_25_0);
6059
private static final Migration MIGRATION_V_0_27_0 = new MigrationV0_27_0(MIGRATION_V_0_26_0);
6160
public static final Migration MIGRATION_V_0_28_0 = new MigrationV0_28_0(MIGRATION_V_0_27_0);
62-
private static final Migration MIGRATION_V_0_29_0 = new MigrationV0_29_0(MIGRATION_V_0_28_0);
63-
private static final Migration MIGRATION_V_0_30_0 = new MigrationV0_30_0(MIGRATION_V_0_29_0);
61+
public static final Migration MIGRATION_V_0_29_0 = new MigrationV0_29_0(MIGRATION_V_0_28_0);
6462

6563
// all migrations must be added to the list in the order that they should be applied.
6664
public static final List<Migration> MIGRATIONS = ImmutableList.of(
@@ -80,7 +78,6 @@ public class Migrations {
8078
MIGRATION_V_0_26_0,
8179
MIGRATION_V_0_27_0,
8280
MIGRATION_V_0_28_0,
83-
MIGRATION_V_0_29_0,
84-
MIGRATION_V_0_30_0);
81+
MIGRATION_V_0_29_0);
8582

8683
}

airbyte-migration/src/main/java/io/airbyte/migrate/migrations/MigrationV0_30_0.java

-101
This file was deleted.

airbyte-migration/src/main/resources/migrations/migrationV0_30_0/airbyte_config/Notification.yaml

-24
This file was deleted.

airbyte-migration/src/main/resources/migrations/migrationV0_30_0/airbyte_config/NotificationType.yaml

-8
This file was deleted.

airbyte-migration/src/main/resources/migrations/migrationV0_30_0/airbyte_config/SlackNotificationConfiguration.yaml

-12
This file was deleted.

airbyte-migration/src/main/resources/migrations/migrationV0_30_0/airbyte_config/StandardWorkspace.yaml

-45
This file was deleted.

airbyte-migration/src/test/java/io/airbyte/migrate/MigrationCurrentSchemaTest.java

+6-74
Original file line numberDiff line numberDiff line change
@@ -26,86 +26,18 @@
2626

2727
import static org.junit.jupiter.api.Assertions.assertEquals;
2828

29-
import com.fasterxml.jackson.databind.JsonNode;
30-
import io.airbyte.commons.enums.Enums;
31-
import java.nio.file.Path;
32-
import java.util.Comparator;
33-
import java.util.List;
34-
import java.util.Map;
35-
import java.util.Map.Entry;
36-
import java.util.stream.Collectors;
37-
import org.junit.jupiter.api.Disabled;
3829
import org.junit.jupiter.api.Test;
3930

4031
public class MigrationCurrentSchemaTest {
4132

42-
// get all of the "current" configs (in other words the one airbyte-config). get all of the configs
43-
// from the output schema of the last migration. make sure they match.
33+
/**
34+
* The file-based migration is deprecated. We need to ensure that v0.29.0 is the last one. All new
35+
* migrations should be written in Flyway.
36+
*/
4437
@Test
45-
void testConfigsOfLastMigrationMatchSource() {
46-
final Map<ResourceId, JsonNode> lastMigrationSchema = getSchemaOfLastMigration(ResourceType.CONFIG);
47-
final Map<ResourceId, JsonNode> currentSchema = MigrationUtils.getNameToSchemasFromResourcePath(
48-
Path.of("types"),
49-
ResourceType.CONFIG,
50-
Enums.valuesAsStrings(ConfigKeys.class));
51-
52-
assertSameSchemas(currentSchema, lastMigrationSchema);
53-
}
54-
55-
private static Map<ResourceId, JsonNode> getSchemaOfLastMigration(ResourceType resourceType) {
38+
public void testLastMigration() {
5639
final Migration lastMigration = Migrations.MIGRATIONS.get(Migrations.MIGRATIONS.size() - 1);
57-
final Map<ResourceId, JsonNode> lastMigrationOutputSchema = lastMigration.getOutputSchema();
58-
59-
return lastMigrationOutputSchema.entrySet()
60-
.stream()
61-
.filter(entry -> entry.getKey().getType() == resourceType)
62-
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));
63-
}
64-
65-
// get all of the "current" jobs (in other words the one airbyte-db). get all of the configs
66-
// from the output schema of the last migration. make sure they match.
67-
@Test
68-
@Disabled
69-
// TODO(#5902): Liren will adapt this to the new migration system.
70-
void testJobsOfLastMigrationMatchSource() {
71-
final Map<ResourceId, JsonNode> lastMigrationSchema = getSchemaOfLastMigration(ResourceType.JOB);
72-
final Map<ResourceId, JsonNode> currentSchema = MigrationUtils.getNameToSchemasFromResourcePath(
73-
Path.of("jobs_database"),
74-
ResourceType.JOB,
75-
Enums.valuesAsStrings(JobKeys.class));
76-
77-
assertSameSchemas(currentSchema, lastMigrationSchema);
78-
}
79-
80-
private static void assertSameSchemas(Map<ResourceId, JsonNode> currentSchemas, Map<ResourceId, JsonNode> lastMigrationSchema) {
81-
assertEquals(currentSchemas.size(), lastMigrationSchema.size());
82-
83-
final List<Entry<ResourceId, JsonNode>> lastMigrationOutputSchemaCleanedSorted = lastMigrationSchema.entrySet()
84-
.stream()
85-
.sorted(Comparator.comparing((v) -> v.getKey().getType()))
86-
.collect(Collectors.toList());
87-
88-
// break out element-wise assertion so it is easier to read any failed tests.
89-
for (Map.Entry<ResourceId, JsonNode> lastMigrationEntry : lastMigrationOutputSchemaCleanedSorted) {
90-
assertEquals(currentSchemas.get(lastMigrationEntry.getKey()), lastMigrationEntry.getValue());
91-
}
92-
}
93-
94-
public enum ConfigKeys {
95-
STANDARD_WORKSPACE,
96-
STANDARD_SOURCE_DEFINITION,
97-
STANDARD_DESTINATION_DEFINITION,
98-
SOURCE_CONNECTION,
99-
DESTINATION_CONNECTION,
100-
STANDARD_SYNC,
101-
STANDARD_SYNC_SCHEDULE,
102-
STANDARD_SYNC_OPERATION,
103-
}
104-
105-
public enum JobKeys {
106-
JOBS,
107-
ATTEMPTS,
108-
AIRBYTE_METADATA
40+
assertEquals(Migrations.MIGRATION_V_0_29_0.getVersion(), lastMigration.getVersion());
10941
}
11042

11143
}

0 commit comments

Comments
 (0)