From 8725a44e40e0c16ab84280f422ff3097d85d4fae Mon Sep 17 00:00:00 2001 From: "pasqualino.cristaudo" <> Date: Thu, 26 Oct 2023 18:36:36 +0200 Subject: [PATCH] Updated init_table.sql and schema-h2.sql scripts --- .../changes/init_table/init_table.sql | 18 ++++++++++----- src/test/resources/schema-h2.sql | 22 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/main/resources/db/changelog/changes/init_table/init_table.sql b/src/main/resources/db/changelog/changes/init_table/init_table.sql index 3f5359a..8c7680b 100644 --- a/src/main/resources/db/changelog/changes/init_table/init_table.sql +++ b/src/main/resources/db/changelog/changes/init_table/init_table.sql @@ -1,30 +1,35 @@ CREATE TABLE IF NOT EXISTS ESERVICE ( eservice_id VARCHAR (50) UNIQUE NOT NULL, producer_id VARCHAR (50) NOT NULL, + descriptor_id VARCHAR (50) NOT NULL, event_id BIGINT NOT NULL, state VARCHAR (50) NOT NULL, tmst_insert TIMESTAMP NOT NULL, tmst_last_edit TIMESTAMP, - UNIQUE (eservice_id, producer_id), - PRIMARY KEY (eservice_id, producer_id) + UNIQUE (eservice_id, producer_id, descriptor_id), + PRIMARY KEY (eservice_id, producer_id, descriptor_id) ); CREATE INDEX IF NOT EXISTS ESERVICE_INDEX_ID ON ESERVICE USING hash (eservice_id); CREATE INDEX IF NOT EXISTS ESERVICE_INDEX_PRODUCER_ID ON ESERVICE USING hash (producer_id); +CREATE INDEX IF NOT EXISTS ESERVICE_INDEX_DESCRIPTOR_ID ON ESERVICE USING hash (descriptor_id); CREATE TABLE IF NOT EXISTS CONSUMER_ESERVICE ( eservice_id VARCHAR (50) NOT NULL, consumer_id VARCHAR (50) NOT NULL, + agreement_id VARCHAR (50) NOT NULL, + descriptor_id VARCHAR (50) NOT NULL, event_id BIGINT NOT NULL, state VARCHAR (50) NOT NULL, tmst_insert TIMESTAMP NOT NULL, tmst_last_edit TIMESTAMP, - UNIQUE (eservice_id, consumer_id), - PRIMARY KEY (eservice_id, consumer_id) + UNIQUE (eservice_id, consumer_id, descriptor_id), + PRIMARY KEY (eservice_id, consumer_id, descriptor_id) ); CREATE INDEX IF NOT EXISTS CONSUMER_ESERVICE_INDEX_ID ON CONSUMER_ESERVICE USING hash (eservice_id); -CREATE INDEX IF NOT EXISTS ESERVICE_INDEX_CONSUMER_ID ON CONSUMER_ESERVICE USING hash (consumer_id); +CREATE INDEX IF NOT EXISTS CONSUMER_ESERVICE_INDEX_CONSUMER_ID ON CONSUMER_ESERVICE USING hash (consumer_id); +CREATE INDEX IF NOT EXISTS CONSUMER_ESERVICE_INDEX_DESCRIPTOR_ID ON CONSUMER_ESERVICE USING hash (descriptor_id); CREATE TABLE IF NOT EXISTS SIGNAL ( @@ -70,6 +75,7 @@ CREATE TABLE IF NOT EXISTS DEAD_EVENT ( event_id BIGINT NOT NULL, event_type VARCHAR (50) NOT NULL, object_type VARCHAR (50) NOT NULL, + descriptor_id VARCHAR (50) NOT NULL, eservice_id VARCHAR (50), agreement_id VARCHAR (50) -); +); \ No newline at end of file diff --git a/src/test/resources/schema-h2.sql b/src/test/resources/schema-h2.sql index c210a25..eb4d119 100644 --- a/src/test/resources/schema-h2.sql +++ b/src/test/resources/schema-h2.sql @@ -1,32 +1,37 @@ CREATE TABLE IF NOT EXISTS ESERVICE ( eservice_id VARCHAR (50) UNIQUE NOT NULL, producer_id VARCHAR (50) NOT NULL, + descriptor_id VARCHAR (50) NOT NULL, event_id BIGINT NOT NULL, state VARCHAR (50) NOT NULL, tmst_insert TIMESTAMP NOT NULL, tmst_last_edit TIMESTAMP, - UNIQUE (eservice_id, producer_id), - PRIMARY KEY (eservice_id, producer_id) + UNIQUE (eservice_id, producer_id, descriptor_id), + PRIMARY KEY (eservice_id, producer_id, descriptor_id) ); /* -CREATE INDEX IF NOT EXISTS ESERVICE_INDEX_ID ON ESERVICE (eservice_id); -CREATE INDEX IF NOT EXISTS ESERVICE_INDEX_PRODUCER_ID ON ESERVICE (producer_id); +CREATE INDEX IF NOT EXISTS ESERVICE_INDEX_ID ON ESERVICE USING hash (eservice_id); +CREATE INDEX IF NOT EXISTS ESERVICE_INDEX_PRODUCER_ID ON ESERVICE USING hash (producer_id); +CREATE INDEX IF NOT EXISTS ESERVICE_INDEX_DESCRIPTOR_ID ON ESERVICE USING hash (descriptor_id); */ CREATE TABLE IF NOT EXISTS CONSUMER_ESERVICE ( eservice_id VARCHAR (50) NOT NULL, consumer_id VARCHAR (50) NOT NULL, + agreement_id VARCHAR (50) NOT NULL, + descriptor_id VARCHAR (50) NOT NULL, event_id BIGINT NOT NULL, state VARCHAR (50) NOT NULL, tmst_insert TIMESTAMP NOT NULL, tmst_last_edit TIMESTAMP, - UNIQUE (eservice_id, consumer_id), - PRIMARY KEY (eservice_id, consumer_id) + UNIQUE (eservice_id, consumer_id, descriptor_id), + PRIMARY KEY (eservice_id, consumer_id, descriptor_id) ); /* -CREATE INDEX IF NOT EXISTS CONSUMER_ESERVICE_INDEX_ID ON CONSUMER_ESERVICE (eservice_id); -CREATE INDEX IF NOT EXISTS ESERVICE_INDEX_CONSUMER_ID ON CONSUMER_ESERVICE (consumer_id); +CREATE INDEX IF NOT EXISTS CONSUMER_ESERVICE_INDEX_ID ON CONSUMER_ESERVICE USING hash (eservice_id); +CREATE INDEX IF NOT EXISTS CONSUMER_ESERVICE_INDEX_CONSUMER_ID ON CONSUMER_ESERVICE USING hash (consumer_id); +CREATE INDEX IF NOT EXISTS CONSUMER_ESERVICE_INDEX_DESCRIPTOR_ID ON CONSUMER_ESERVICE USING hash (descriptor_id); */ @@ -76,6 +81,7 @@ CREATE TABLE IF NOT EXISTS DEAD_EVENT ( event_id BIGINT NOT NULL, event_type VARCHAR (50) NOT NULL, object_type VARCHAR (50) NOT NULL, + descriptor_id VARCHAR (50) NOT NULL, eservice_id VARCHAR (50), agreement_id VARCHAR (50) ); \ No newline at end of file