-
Notifications
You must be signed in to change notification settings - Fork 4.5k
🎉 Migrate config persistence to database #4670
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
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
6ec78f2
Implement db config persistence
tuliren 947d03a
Fix database readiness check
tuliren e83c373
Reduce logging noise
tuliren dc86c62
Setup config database in config persistence factory
tuliren 648ce17
Update documentation
tuliren e72843c
Load seed from yaml files
tuliren 1067aa4
Refactor config persistence factory
tuliren 607bf07
Add one more test to mimic migration
tuliren 33ed1cd
Remove unnecessary changes
tuliren 19a8f2e
Run code formatter
tuliren 3a9db90
Merge branch 'master' into liren/db-config-persistence-v2
tuliren 6fb38bf
Update placeholder env values
tuliren 576f28d
Set default config database parameters in docker compose
tuliren 8b85a03
Default setupDatabase to false
tuliren d62a72b
Rename variable
tuliren d7e4815
Set default config db parameters for server
tuliren 91f2f77
Remove config db parameters from the env file
tuliren dc14826
Remove unnecessary environment statements
tuliren 9be88a3
Merge branch 'master' into liren/db-config-persistence-v2
tuliren 991a374
Hide config persistence factory (#4772)
cgardens 7b845ce
Remove CONFIG_DATABASE_HOST
tuliren c2f9275
Use builder in the test
tuliren 865e11b
Simplify config persistence builder
tuliren d88e663
Clarify config db connection readiness
tuliren ee9b3ea
Format code
tuliren 1d7741e
Add logging
tuliren c29bb7e
Fix typo
tuliren ad9c982
Merge branch 'master' into liren/db-config-persistence-v2
tuliren 0c68bc0
Add a config_id only index
tuliren 86ee51e
Reuse record insertion code
tuliren d6b95b2
Add id field name to config schema
tuliren 03ac64a
Support data loading from legacy config schemas
tuliren 7537864
Log missing logs in migration test
tuliren 024253b
Move airbyte configs table to separate directory
tuliren ae638ef
Update exception message
tuliren 0d22400
Dump specific tables from the job database
tuliren c0ce70d
Remove postgres specific uuid extension
tuliren d76f58f
Comment out future branch
tuliren 3d99a73
Default configs db variables to empty
tuliren d99cda7
Merge master into liren/db-config-persistence-v2
tuliren 449cb30
Log inserted config records
tuliren d37b9fc
Log all db write operations
tuliren 3461382
Add back config db variables in env file to mute warnings
tuliren fb0638e
Log connection exception to debug flaky e2e test
tuliren 10cabfa
Leave config db variables empty
tuliren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! This has bitten us a few times...