From a2eed4e3fa12e5fa5f30051574c5eb4b3d127867 Mon Sep 17 00:00:00 2001 From: Chris Richardson Date: Thu, 15 Dec 2022 21:33:27 -0800 Subject: [PATCH] #91 Use flyway to configure eventuate DB schema --- .../flyway/mysql/V1000__tram-saga-schema.sql | 37 +++++++++++++++++++ .../postgresql/V1000__tram-saga-schema.sql | 35 ++++++++++++++++++ settings.gradle | 3 ++ 3 files changed, 75 insertions(+) create mode 100644 eventuate-tram-sagas-spring-flyway/src/main/resources/flyway/mysql/V1000__tram-saga-schema.sql create mode 100644 eventuate-tram-sagas-spring-flyway/src/main/resources/flyway/postgresql/V1000__tram-saga-schema.sql diff --git a/eventuate-tram-sagas-spring-flyway/src/main/resources/flyway/mysql/V1000__tram-saga-schema.sql b/eventuate-tram-sagas-spring-flyway/src/main/resources/flyway/mysql/V1000__tram-saga-schema.sql new file mode 100644 index 0000000..f83e05f --- /dev/null +++ b/eventuate-tram-sagas-spring-flyway/src/main/resources/flyway/mysql/V1000__tram-saga-schema.sql @@ -0,0 +1,37 @@ + +CREATE TABLE saga_instance_participants ( + saga_type VARCHAR(255) NOT NULL, + saga_id VARCHAR(100) NOT NULL, + destination VARCHAR(100) NOT NULL, + resource VARCHAR(100) NOT NULL, + PRIMARY KEY(saga_type, saga_id, destination, resource) +); + + +CREATE TABLE saga_instance( + saga_type VARCHAR(255) NOT NULL, + saga_id VARCHAR(100) NOT NULL, + state_name VARCHAR(100) NOT NULL, + last_request_id VARCHAR(100), + end_state INT(1), + compensating INT(1), + failed INT(1), + saga_data_type VARCHAR(1000) NOT NULL, + saga_data_json VARCHAR(1000) NOT NULL, + PRIMARY KEY(saga_type, saga_id) +); + +create table saga_lock_table( + target VARCHAR(100) PRIMARY KEY, + saga_type VARCHAR(255) NOT NULL, + saga_Id VARCHAR(100) NOT NULL +); + +create table saga_stash_table( + message_id VARCHAR(100) PRIMARY KEY, + target VARCHAR(100) NOT NULL, + saga_type VARCHAR(255) NOT NULL, + saga_id VARCHAR(100) NOT NULL, + message_headers VARCHAR(1000) NOT NULL, + message_payload VARCHAR(1000) NOT NULL +); \ No newline at end of file diff --git a/eventuate-tram-sagas-spring-flyway/src/main/resources/flyway/postgresql/V1000__tram-saga-schema.sql b/eventuate-tram-sagas-spring-flyway/src/main/resources/flyway/postgresql/V1000__tram-saga-schema.sql new file mode 100644 index 0000000..4870951 --- /dev/null +++ b/eventuate-tram-sagas-spring-flyway/src/main/resources/flyway/postgresql/V1000__tram-saga-schema.sql @@ -0,0 +1,35 @@ +CREATE TABLE saga_instance_participants ( + saga_type VARCHAR(255) NOT NULL, + saga_id VARCHAR(100) NOT NULL, + destination VARCHAR(100) NOT NULL, + resource VARCHAR(100) NOT NULL, + PRIMARY KEY(saga_type, saga_id, destination, resource) +); + +CREATE TABLE saga_instance( + saga_type VARCHAR(255) NOT NULL, + saga_id VARCHAR(100) NOT NULL, + state_name VARCHAR(100) NOT NULL, + last_request_id VARCHAR(100), + end_state BOOLEAN, + compensating BOOLEAN, + failed BOOLEAN, + saga_data_type VARCHAR(1000) NOT NULL, + saga_data_json VARCHAR(1000) NOT NULL, + PRIMARY KEY(saga_type, saga_id) +); + +create table saga_lock_table( + target VARCHAR(100) PRIMARY KEY, + saga_type VARCHAR(255) NOT NULL, + saga_Id VARCHAR(100) NOT NULL +); + +create table saga_stash_table( + message_id VARCHAR(100) PRIMARY KEY, + target VARCHAR(100) NOT NULL, + saga_type VARCHAR(255) NOT NULL, + saga_id VARCHAR(100) NOT NULL, + message_headers VARCHAR(1000) NOT NULL, + message_payload VARCHAR(1000) NOT NULL +); \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 123d181..39865e2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -43,4 +43,7 @@ include 'orders-and-customers-micronaut-local-saga-in-memory-integration-tests' include 'eventuate-tram-sagas-spring-orchestration-simple-dsl-starter' include 'eventuate-tram-sagas-spring-reactive-participant-starter' include 'eventuate-tram-sagas-spring-participant-starter' + +include 'eventuate-tram-sagas-spring-flyway' + include 'eventuate-tram-sagas-bom'