-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉 Migrate config persistence to database (#4670)
* Implement db config persistence * Fix database readiness check * Reduce logging noise * Setup config database in config persistence factory * Update documentation * Load seed from yaml files * Refactor config persistence factory * Add one more test to mimic migration * Remove unnecessary changes * Run code formatter * Update placeholder env values * Set default config database parameters in docker compose Co-authored-by: Christophe Duong <[email protected]> * Default setupDatabase to false * Rename variable * Set default config db parameters for server * Remove config db parameters from the env file * Remove unnecessary environment statements * Hide config persistence factory (#4772) * Remove CONFIG_DATABASE_HOST * Use builder in the test * Simplify config persistence builder * Clarify config db connection readiness * Format code * Add logging * Fix typo Co-authored-by: Christophe Duong <[email protected]> * Add a config_id only index * Reuse record insertion code * Add id field name to config schema * Support data loading from legacy config schemas * Log missing logs in migration test * Move airbyte configs table to separate directory * Update exception message * Dump specific tables from the job database * Remove postgres specific uuid extension * Comment out future branch * Default configs db variables to empty When defaulting them to the jobs db variables, it somehow does not work. * Log inserted config records * Log all db write operations * Add back config db variables in env file to mute warnings * Log connection exception to debug flaky e2e test * Leave config db variables empty `.env` file does not support variable expansion. Co-authored-by: Christophe Duong <[email protected]> Co-authored-by: Charles <[email protected]>
- Loading branch information
1 parent
f4018c5
commit e577b49
Showing
30 changed files
with
1,521 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
airbyte-config/init/src/main/resources/seed/workspace_definitions.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- workspaceId: 5ae6b09b-fdec-41af-aaf7-7d94cfc33ef6 | ||
name: default | ||
slug: default | ||
initialSetupComplete: false | ||
displaySetupWizard: true | ||
tombstone: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
airbyte-config/models/src/main/java/io/airbyte/config/ConfigSchemaMigrationSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.config; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* When migrating configs, it is possible that some of the old config types have been removed from | ||
* the codebase. So we cannot rely on the latest {@link ConfigSchema} to migrate them. This class | ||
* provides backward compatibility for those legacy config types during migration. | ||
*/ | ||
public class ConfigSchemaMigrationSupport { | ||
|
||
// a map from config schema to its id field names | ||
public static final Map<String, String> CONFIG_SCHEMA_ID_FIELD_NAMES; | ||
|
||
static { | ||
Map<String, String> currentConfigSchemaIdNames = Arrays.stream(ConfigSchema.values()) | ||
.filter(configSchema -> configSchema.getIdFieldName() != null) | ||
.collect(Collectors.toMap(Enum::name, ConfigSchema::getIdFieldName)); | ||
CONFIG_SCHEMA_ID_FIELD_NAMES = new ImmutableMap.Builder<String, String>() | ||
.putAll(currentConfigSchemaIdNames) | ||
// add removed config schema and its id field names below | ||
// https://github.com/airbytehq/airbyte/pull/41 | ||
.put("SOURCE_CONNECTION_CONFIGURATION", "sourceSpecificationId") | ||
.put("DESTINATION_CONNECTION_CONFIGURATION", "destinationSpecificationId") | ||
// https://github.com/airbytehq/airbyte/pull/528 | ||
.put("SOURCE_CONNECTION_SPECIFICATION", "sourceSpecificationId") | ||
.put("DESTINATION_CONNECTION_SPECIFICATION", "destinationSpecificationId") | ||
// https://github.com/airbytehq/airbyte/pull/564 | ||
.put("STANDARD_SOURCE", "sourceId") | ||
.put("STANDARD_DESTINATION", "destinationId") | ||
.put("SOURCE_CONNECTION_IMPLEMENTATION", "sourceImplementationId") | ||
.put("DESTINATION_CONNECTION_IMPLEMENTATION", "destinationImplementationId") | ||
// https://github.com/airbytehq/airbyte/pull/3472 | ||
.put("STANDARD_SYNC_SCHEDULE", "connectionId") | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
dependencies { | ||
implementation group: 'commons-io', name: 'commons-io', version: '2.7' | ||
|
||
implementation project(':airbyte-db') | ||
implementation project(':airbyte-config:models') | ||
implementation project(":airbyte-json-validation") | ||
implementation project(':airbyte-config:init') | ||
implementation project(':airbyte-json-validation') | ||
|
||
testImplementation "org.testcontainers:postgresql:1.15.1" | ||
} |
47 changes: 47 additions & 0 deletions
47
...e-config/persistence/src/main/java/io/airbyte/config/persistence/AirbyteConfigsTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.config.persistence; | ||
|
||
import static org.jooq.impl.DSL.field; | ||
import static org.jooq.impl.DSL.table; | ||
|
||
import java.sql.Timestamp; | ||
import org.jooq.Field; | ||
import org.jooq.JSONB; | ||
import org.jooq.Record; | ||
import org.jooq.Table; | ||
|
||
public class AirbyteConfigsTable { | ||
|
||
public static final String AIRBYTE_CONFIGS_TABLE_SCHEMA = "airbyte_configs_table.sql"; | ||
|
||
public static final Table<Record> AIRBYTE_CONFIGS = table("airbyte_configs"); | ||
public static final Field<String> CONFIG_ID = field("config_id", String.class); | ||
public static final Field<String> CONFIG_TYPE = field("config_type", String.class); | ||
public static final Field<JSONB> CONFIG_BLOB = field("config_blob", JSONB.class); | ||
public static final Field<Timestamp> CREATED_AT = field("created_at", Timestamp.class); | ||
public static final Field<Timestamp> UPDATED_AT = field("updated_at", Timestamp.class); | ||
|
||
} |
Oops, something went wrong.