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

Add parameter for db schema #454

Merged
Show file tree
Hide file tree
Changes from 6 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
9 changes: 9 additions & 0 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,14 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-java

# create non-default schema name to test usage of non-default schema
- name: setup postgres schema
run: |
sudo apt update
sudo apt install --yes postgresql-client
psql -h localhost -d postgres -U postgres -c 'CREATE SCHEMA testschema;'
env:
PGPASSWORD: password

- name: Run Postgresql E2E tests
run: ./gradlew test -DincludeTags="PostgresqlIntegrationTest"
12 changes: 12 additions & 0 deletions edc-extensions/postgresql-migration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@ This extension applies SQL migrations to
* contract-negotiation store
* policy store
* transfer-process store

## Configuration

| Key | Description | Mandatory | Default |
|:--------------------------------------------------------------------------|:-------------------------------------------------|-----------|----------|
| org.eclipse.tractusx.edc.postgresql.migration.asset.enabled | Enable migration for asset tables | | true |
| org.eclipse.tractusx.edc.postgresql.migration.contractdefinition.enabled | Enable migration for contract definition tables | | true |
| org.eclipse.tractusx.edc.postgresql.migration.contractnegotiation.enabled | Enable migration for contract negotiation tables | | true |
| org.eclipse.tractusx.edc.postgresql.migration.edr.enabled | Enable migration for edr tables | | true |
| org.eclipse.tractusx.edc.postgresql.migration.policy.enabled | Enable migration for policy tables | | true |
| org.eclipse.tractusx.edc.postgresql.migration.transferprocess.enabled | Enable migration for transfer process tables | | true |
| org.eclipse.tractusx.edc.postgresql.migration.schema | The DB schema to be used during migration | | "public" |
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public void initialize(final ServiceExtensionContext context) {

boolean enabled = context.getConfig()
.getBoolean(String.format("org.eclipse.tractusx.edc.postgresql.migration.%s.enabled", subSystemName), true);
String schema = context.getConfig()
.getString("org.eclipse.tractusx.edc.postgresql.migration.schema", "public");

if (!enabled) {
return;
Expand All @@ -79,6 +81,7 @@ public void initialize(final ServiceExtensionContext context) {
.dataSource(dataSource)
.table(schemaHistoryTableName)
.locations(migrationsLocation)
.defaultSchema(schema)
.load();

flyway.baseline();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class TestRuntimeConfiguration {
static final String SOKRATES_DATAPLANE_CONTROL_PORT = String.valueOf(getFreePort());

static final String SOKRATES_DATAPLANE_PROXY_PORT = String.valueOf(getFreePort());

static final String DB_SCHEMA_NAME = "testschema";

public static Map<String, String> sokratesPostgresqlConfiguration() {
var baseConfiguration = sokratesConfiguration();
Expand Down Expand Up @@ -94,6 +96,8 @@ public static Map<String, String> postgresqlConfiguration(String name) {
put("edc.datasource.edr.url", jdbcUrl);
put("edc.datasource.edr.user", PostgresqlLocalInstance.USER);
put("edc.datasource.edr.password", PostgresqlLocalInstance.PASSWORD);
// use non-default schema name to test usage of non-default schema
put("org.eclipse.tractusx.edc.postgresql.migration.schema", DB_SCHEMA_NAME);
}
};
}
Expand Down Expand Up @@ -164,6 +168,6 @@ public static Map<String, String> platoConfiguration() {

@NotNull
public static String jdbcUrl(String name) {
return PostgresqlLocalInstance.JDBC_URL_PREFIX + name;
return PostgresqlLocalInstance.JDBC_URL_PREFIX + name + "?currentSchema=" + DB_SCHEMA_NAME;
}
}