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 c827493..ed0337c 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 @@ -2,39 +2,36 @@ CREATE TABLE IF NOT EXISTS ESERVICE ( eservice_id VARCHAR (50) NOT NULL, producer_id VARCHAR (50) NOT NULL, descriptor_id VARCHAR (50) NOT NULL, - event_id BIGINT , + event_id BIGINT, state VARCHAR (50) NOT NULL, tmst_insert TIMESTAMP DEFAULT CURRENT_TIMESTAMP, tmst_last_edit TIMESTAMP, - UNIQUE (eservice_id, producer_id, descriptor_id), - PRIMARY KEY (eservice_id, producer_id, descriptor_id) + UNIQUE (eservice_id, producer_id), + PRIMARY KEY (eservice_id, 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 ( - agreement_id VARCHAR (50) NOT NULL, - eservice_id VARCHAR (50) NOT NULL, - consumer_id VARCHAR (50) NOT NULL, - descriptor_id VARCHAR (50) NOT NULL, - event_id BIGINT , - state VARCHAR (50) NOT NULL, - tmst_insert TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - tmst_last_edit TIMESTAMP, - PRIMARY KEY (agreement_id) + agreement_id VARCHAR (50) NOT NULL, + eservice_id VARCHAR (50) NOT NULL, + consumer_id VARCHAR (50) NOT NULL, + descriptor_id VARCHAR (50) NOT NULL, + event_id BIGINT, + state VARCHAR (50) NOT NULL, + tmst_insert TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + tmst_last_edit TIMESTAMP, + 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 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 ( - id SERIAL PRIMARY KEY, + id SERIAL PRIMARY KEY, correlation_id VARCHAR(50) NOT NULL, signal_id BIGINT NOT NULL, object_id VARCHAR (50) NOT NULL, @@ -49,7 +46,7 @@ CREATE INDEX IF NOT EXISTS SIGNAL_INDEX_ESERVICE_ID ON SIGNAL USING hash (eservi CREATE TABLE IF NOT EXISTS DEAD_SIGNAL ( - id SERIAL PRIMARY KEY, + id SERIAL PRIMARY KEY, correlation_id VARCHAR(50) NOT NULL, signal_id BIGINT NOT NULL, object_id VARCHAR (50) NOT NULL, @@ -62,13 +59,14 @@ CREATE TABLE IF NOT EXISTS DEAD_SIGNAL ( CREATE TABLE IF NOT EXISTS TRACING_BATCH ( - batch_id SERIAL PRIMARY KEY, - state VARCHAR (50) NOT NULL, - last_event_id BIGINT, - tmst_started TIMESTAMP NOT NULL, - tmst_ended TIMESTAMP + batch_id SERIAL PRIMARY KEY, + state VARCHAR (50) NOT NULL, + last_event_id BIGINT, + tmst_started TIMESTAMP NOT NULL, + tmst_ended TIMESTAMP ); + CREATE TABLE IF NOT EXISTS DEAD_EVENT ( event_tmp_id SERIAL PRIMARY KEY, tmst_insert TIMESTAMP, diff --git a/src/test/resources/schema-h2.sql b/src/test/resources/schema-h2.sql index ab8b713..68e84b0 100644 --- a/src/test/resources/schema-h2.sql +++ b/src/test/resources/schema-h2.sql @@ -2,41 +2,41 @@ CREATE TABLE IF NOT EXISTS ESERVICE ( eservice_id VARCHAR (50) NOT NULL, producer_id VARCHAR (50) NOT NULL, descriptor_id VARCHAR (50) NOT NULL, - event_id BIGINT , + event_id BIGINT, state VARCHAR (50) NOT NULL, tmst_insert TIMESTAMP DEFAULT CURRENT_TIMESTAMP, tmst_last_edit TIMESTAMP, - UNIQUE (eservice_id, producer_id, descriptor_id), - PRIMARY KEY (eservice_id, producer_id, descriptor_id) + UNIQUE (eservice_id, producer_id), + PRIMARY KEY (eservice_id, 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 ( - agreement_id VARCHAR (50) NOT NULL, - eservice_id VARCHAR (50) NOT NULL, - consumer_id VARCHAR (50) NOT NULL, - descriptor_id VARCHAR (50) NOT NULL, - event_id BIGINT , - state VARCHAR (50) NOT NULL, - tmst_insert TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - tmst_last_edit TIMESTAMP, - PRIMARY KEY (agreement_id) - ); - +CREATE TABLE IF NOT EXISTS CONSUMER_ESERVICE ( + agreement_id VARCHAR (50) NOT NULL, + eservice_id VARCHAR (50) NOT NULL, + consumer_id VARCHAR (50) NOT NULL, + descriptor_id VARCHAR (50) NOT NULL, + event_id BIGINT, + state VARCHAR (50) NOT NULL, + tmst_insert TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + tmst_last_edit TIMESTAMP, + 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 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 ( - id SERIAL PRIMARY KEY, + id SERIAL PRIMARY KEY, correlation_id VARCHAR(50) NOT NULL, signal_id BIGINT NOT NULL, object_id VARCHAR (50) NOT NULL, @@ -53,15 +53,15 @@ CREATE INDEX IF NOT EXISTS SIGNAL_INDEX_ESERVICE_ID ON SIGNAL USING hash (eservi CREATE TABLE IF NOT EXISTS DEAD_SIGNAL ( - id SERIAL PRIMARY KEY, - correlation_id VARCHAR(50) NOT NULL, - signal_id BIGINT NOT NULL, - object_id VARCHAR (50) NOT NULL, - eservice_id VARCHAR (50) NOT NULL, - object_type VARCHAR (50) NOT NULL, - signal_type VARCHAR (50) NOT NULL, - tmst_insert TIMESTAMP NOT NULL, - error_reason VARCHAR(255) NOT NULL + id SERIAL PRIMARY KEY, + correlation_id VARCHAR(50) NOT NULL, + signal_id BIGINT NOT NULL, + object_id VARCHAR (50) NOT NULL, + eservice_id VARCHAR (50) NOT NULL, + object_type VARCHAR (50) NOT NULL, + signal_type VARCHAR (50) NOT NULL, + tmst_insert TIMESTAMP NOT NULL, + error_reason VARCHAR(255) NOT NULL );