Skip to content

Commit

Permalink
Updated to new db-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
kkovarik committed May 15, 2017
1 parent c9c5d25 commit 6fde2de
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public class MutableNode extends AbstractNode {
*/
@Id
@Column(name = "node_id")
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "openhub_node_id_sequence")
@SequenceGenerator(name="openhub_node_id_sequence", sequenceName="openhub_node_sequence", allocationSize=1)
private Long nodeId;

/**
Expand Down
18 changes: 16 additions & 2 deletions core/src/main/resources/db/migration/h2/V1_0__schema_init.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

CREATE TABLE CONFIGURATION_ITEM
(
CODE varchar(255) PRIMARY KEY NOT NULL,
CATEGORY_CODE varchar(100) NOT NULL,
CURRENT_VALUE varchar(1000),
DATA_TYPE varchar(20) NOT NULL,
DEFAULT_VALUE varchar(1000),
DESCRIPTION varchar(1000),
MANDATORY boolean,
VALIDATION varchar(100)
);
Expand All @@ -27,6 +27,7 @@ CREATE TABLE MESSAGE
GUARANTEED_ORDER boolean NOT NULL,
LAST_UPDATE_TIMESTAMP timestamp,
MSG_TIMESTAMP timestamp NOT NULL,
NODE_ID bigint,
OBJECT_ID varchar(50),
OPERATION_NAME varchar(100) NOT NULL,
PARENT_BINDING_TYPE varchar(25),
Expand Down Expand Up @@ -57,6 +58,17 @@ CREATE TABLE EXTERNAL_CALL
);
CREATE UNIQUE INDEX UQ_OPERATION_ENTITY_ID_INDEX_B ON EXTERNAL_CALL (OPERATION_NAME, ENTITY_ID);

CREATE TABLE NODE
(
NODE_ID bigint PRIMARY KEY NOT NULL,
CODE varchar(64) NOT NULL,
DESCRIPTION varchar(2056),
NAME varchar(256) NOT NULL,
STATE varchar(64) NOT NULL
);
CREATE UNIQUE INDEX UK_TCGSVCB1U24GNSRTGKFUUCBR6_INDEX_2 ON NODE (CODE);
CREATE UNIQUE INDEX UK_FWIGXDMJ6BSRPCMHCGPMLSIRH_INDEX_2 ON NODE (NAME);

CREATE TABLE REQUEST
(
REQ_ID bigint PRIMARY KEY NOT NULL,
Expand All @@ -67,6 +79,7 @@ CREATE TABLE REQUEST
URI varchar(400) NOT NULL,
CONSTRAINT FKMB95LWQX0QQN830RWDBAN187O FOREIGN KEY (MSG_ID) REFERENCES MESSAGE (MSG_ID)
);

CREATE TABLE RESPONSE
(
RES_ID bigint PRIMARY KEY NOT NULL,
Expand All @@ -80,4 +93,5 @@ CREATE TABLE RESPONSE
CONSTRAINT FKO1WN9A2359KS1RE952WA3WVTR FOREIGN KEY (REQ_ID) REFERENCES REQUEST (REQ_ID)
);

CREATE SEQUENCE OPENHUB_SEQUENCE;
CREATE SEQUENCE OPENHUB_SEQUENCE;
CREATE SEQUENCE OPENHUB_NODE_SEQUENCE;
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ create table configuration_item (
data_type varchar(20) not null,
-- is this configuration item mandatory? In other worlds must be at least one current or default value defined?
mandatory boolean not null default true,
-- description
description varchar(1000) null,
-- regular expression for checking if current value is valid
validation varchar(100) null,
primary key (code)
Expand All @@ -456,11 +458,42 @@ ALTER TABLE configuration_item OWNER TO openhub;

-- Call db_init-configuration.sql for inserting default configuration items

--
-- tables: node
--

drop table if exists node cascade;

create table node (
node_id int8 not null,
code varchar(64) not null unique,
name varchar(256) not null unique,
description varchar(2056) null,
state varchar(64) not null,
primary key (node_id)
);

alter table node add constraint uq_node_code unique (code);
alter table node add constraint uq_node_name unique (name);

drop index if exists node_code_idx;
create index node_code_idx ON node (code);

ALTER TABLE node OWNER TO openhub;

--
-- sequence for node table
--
-- DB increment script for version 2.0.0
create sequence openhub_node_sequence;

--
-- Update in table message
--

-- adding start_in_queue_timestamp
alter table message add column node_id int8 null;
alter table message add constraint fk_message_node foreign key (node_id) references node;
alter table message add column start_in_queue_timestamp timestamp null;

drop index if exists msg_node_id_idx;
create index msg_node_id_idx ON message (node_id);

This file was deleted.

4 changes: 4 additions & 0 deletions docker/postgresql/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
openhubdb:
build: .
ports:
- "5435:5432"
10 changes: 8 additions & 2 deletions web-admin/src/test/resources/application-h2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ spring.datasource.name=OHF-TEST
# a schema (DDL) script resource reference
#spring.datasource.schema=classpath:db/schema-h2.sql
# a data (DML) script resource reference
spring.datasource.data=classpath:/db/db_init-configuration.sql
#spring.datasource.data=classpath:/db/db_init-configuration.sql
# a charset for reading SQL scripts
spring.datasource.sql-script-encoding=UTF-8
# the platform to use in the schema resource (schema-${platform}.sql)
spring.datasource.platform=h2
#spring.datasource.platform=h2
#spring.datasource.continue-on-error=false # continue even if can't be initialized
#spring.datasource.separator=; # statement separator in SQL initialization scripts
spring.datasource.driver-class-name=org.h2.Driver
Expand All @@ -37,3 +37,9 @@ spring.datasource.hikari.pool-name=OHF-TEST-HikariCP
#spring.datasource.min-evictable-idle-time-millis=
#spring.datasource.max-wait=
#spring.datasource.jmx-enabled=false # Export JMX MBeans (if supported)

# FLYWAY
# Scripts locations
flyway.locations=classpath:db/migration/h2
# Enable flyway
flyway.enabled=true

0 comments on commit 6fde2de

Please sign in to comment.