possibility to run the app with in memory h2 database for integration testing
This commit is contained in:
@@ -99,6 +99,12 @@
|
||||
<version>1.1-groovy-2.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.4.194</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
--liquibase formatted sql
|
||||
|
||||
--changeset michaluk.michal:1.init
|
||||
|
||||
CREATE SEQUENCE hibernate_sequence
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
CREATE CAST (character varying AS json) WITH INOUT AS ASSIGNMENT;
|
||||
11
app-monolith/src/main/resources/schema/commons.xml
Normal file
11
app-monolith/src/main/resources/schema/commons.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
|
||||
<changeSet author="jakubpilimon" id="1.init">
|
||||
<createSequence sequenceName="hibernate_sequence" startValue="1" incrementBy="1" cacheSize="1"/>
|
||||
</changeSet>
|
||||
<changeSet author="jakubpilimon" id="2.postgres.json" dbms="postgresql">
|
||||
<sql>CREATE CAST (character varying AS jsonb) WITH INOUT AS ASSIGNMENT</sql>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -2,10 +2,10 @@
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
|
||||
<include file="/schema/commons.sql"/>
|
||||
<include file="/schema/delivery-planning.sql"/>
|
||||
<include file="/schema/demand-forecasting.sql"/>
|
||||
<include file="/schema/product-management.sql"/>
|
||||
<include file="/schema/production-planning.sql"/>
|
||||
<include file="/schema/shortages-prediction.sql"/>
|
||||
<include file="/schema/commons.xml"/>
|
||||
<include file="/schema/delivery-planning.xml"/>
|
||||
<include file="/schema/demand-forecasting.xml"/>
|
||||
<include file="/schema/product-management.xml"/>
|
||||
<include file="/schema/production-planning.xml"/>
|
||||
<include file="/schema/shortages-prediction.xml"/>
|
||||
</databaseChangeLog>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
--liquibase formatted sql
|
||||
|
||||
--changeset michaluk.michal:1.init
|
||||
CREATE SCHEMA delivery_planning;
|
||||
|
||||
CREATE TABLE delivery_planning.delivery_planner_definition (
|
||||
ref_no character varying(64) NOT NULL PRIMARY KEY,
|
||||
definition json NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE delivery_planning.delivery_forecast (
|
||||
id serial NOT NULL PRIMARY KEY,
|
||||
ref_no character varying(64) NOT NULL,
|
||||
"time" timestamp without time zone NOT NULL,
|
||||
"date" timestamp without time zone NOT NULL,
|
||||
level bigint NOT NULL
|
||||
);
|
||||
42
app-monolith/src/main/resources/schema/delivery-planning.xml
Normal file
42
app-monolith/src/main/resources/schema/delivery-planning.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
|
||||
|
||||
<property name="json" value="clob" dbms="h2"/>
|
||||
<property name="json" value="jsonb" dbms="postgresql"/>
|
||||
|
||||
<changeSet author="jakubpilimon" id="1.delivery-planning-init">
|
||||
<sql>
|
||||
CREATE SCHEMA delivery_planning
|
||||
</sql>
|
||||
|
||||
<createTable tableName="delivery_planner_definition" schemaName="delivery_planning">
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="definition" type="${json}">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
|
||||
<createTable tableName="delivery_forecast" schemaName="delivery_planning">
|
||||
<column name="id" type="serial">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="time" type="timestamp">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="date" type="timestamp">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="level" type="bigint">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -1,49 +0,0 @@
|
||||
--liquibase formatted sql
|
||||
|
||||
--changeset michaluk.michal:1.init
|
||||
CREATE SCHEMA demand_forecasting;
|
||||
|
||||
CREATE TABLE demand_forecasting.product_demand (
|
||||
id serial NOT NULL PRIMARY KEY,
|
||||
version bigint NOT NULL,
|
||||
ref_no character varying(64) NOT NULL,
|
||||
UNIQUE(ref_no)
|
||||
);
|
||||
|
||||
CREATE TABLE demand_forecasting."demand" (
|
||||
id serial NOT NULL PRIMARY KEY,
|
||||
ref_no character varying(64) NOT NULL,
|
||||
"date" timestamp without time zone NOT NULL,
|
||||
value json NOT NULL,
|
||||
UNIQUE(ref_no, "date")
|
||||
);
|
||||
|
||||
CREATE TABLE demand_forecasting.current_demand (
|
||||
id serial NOT NULL PRIMARY KEY,
|
||||
ref_no character varying(64) NOT NULL,
|
||||
"date" timestamp without time zone NOT NULL,
|
||||
level bigint NOT NULL,
|
||||
"schema" character varying(64) NOT NULL,
|
||||
UNIQUE(ref_no, "date")
|
||||
);
|
||||
|
||||
CREATE TABLE demand_forecasting.demand_adjustment (
|
||||
id serial NOT NULL PRIMARY KEY,
|
||||
customer_representative character varying(255) NOT NULL,
|
||||
note character varying(255) NOT NULL,
|
||||
adjustment json NOT NULL,
|
||||
clean_after timestamp without time zone
|
||||
);
|
||||
|
||||
CREATE TABLE demand_forecasting.demand_review (
|
||||
id serial NOT NULL PRIMARY KEY,
|
||||
ref_no character varying(64) NOT NULL,
|
||||
"date" timestamp without time zone NOT NULL,
|
||||
"timestamp" timestamp without time zone NOT NULL,
|
||||
review json NOT NULL,
|
||||
decision character varying(64),
|
||||
clean_after timestamp without time zone
|
||||
);
|
||||
|
||||
--changeset michaluk.michal:2.rename.review.table
|
||||
ALTER TABLE demand_forecasting.demand_review RENAME TO required_review;
|
||||
134
app-monolith/src/main/resources/schema/demand-forecasting.xml
Normal file
134
app-monolith/src/main/resources/schema/demand-forecasting.xml
Normal file
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
|
||||
|
||||
<property name="json" value="clob" dbms="h2"/>
|
||||
<property name="json" value="jsonb" dbms="postgresql"/>
|
||||
|
||||
<changeSet author="jakubpilimon" id="1.demand_forecasting-init">
|
||||
<sql>
|
||||
CREATE SCHEMA demand_forecasting
|
||||
</sql>
|
||||
|
||||
<createTable tableName="product_demand" schemaName="demand_forecasting">
|
||||
<column name="id" type="serial">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="version" type="bigint">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints unique="true"/>
|
||||
</column>
|
||||
</createTable>
|
||||
|
||||
<createTable tableName="demand" schemaName="demand_forecasting">
|
||||
<column name="id" type="serial">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="date" type="timestamp">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="value" type="${json}">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
<addUniqueConstraint
|
||||
columnNames="ref_no, date"
|
||||
constraintName="demand_refno_date_unique"
|
||||
schemaName="demand_forecasting"
|
||||
tableName="demand"/>
|
||||
|
||||
<createTable tableName="current_demand" schemaName="demand_forecasting">
|
||||
<column name="id" type="serial">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="date" type="timestamp">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="level" type="bigint">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="schema" type="varchar(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
<addUniqueConstraint
|
||||
columnNames="ref_no, date"
|
||||
constraintName="cr_demand_refno_date_unique"
|
||||
schemaName="demand_forecasting"
|
||||
tableName="current_demand"/>
|
||||
|
||||
<createTable tableName="demand_adjustment" schemaName="demand_forecasting">
|
||||
<column name="id" type="serial">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="customer_representative" type="varchar(255)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="note" type="varchar(255)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="adjustment" type="${json}">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="clean_after" type="timestamp"/>
|
||||
</createTable>
|
||||
|
||||
<createTable tableName="demand_review" schemaName="demand_forecasting">
|
||||
<column name="id" type="serial">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="date" type="timestamp">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="timestamp" type="timestamp">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="review" type="${json}">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="decision" type="varchar(64)"/>
|
||||
<column name="clean_after" type="timestamp"/>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="jakubpilimon" id="2.rename.review.table">
|
||||
<renameTable oldTableName="demand_review" newTableName="required_review" schemaName="demand_forecasting"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="jakubpilimon" id="3.create.document.table">
|
||||
<createTable tableName="document" schemaName="demand_forecasting">
|
||||
<column name="id" type="serial">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="original_uri" type="varchar(1024)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="stored_uri" type="varchar(1024)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="saved" type="timestamp">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="document" type="${json}">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="clean_after" type="timestamp"/>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -1,9 +0,0 @@
|
||||
--liquibase formatted sql
|
||||
|
||||
--changeset michaluk.michal:1.init
|
||||
CREATE SCHEMA product_management;
|
||||
|
||||
CREATE TABLE product_management.product_description (
|
||||
ref_no character varying(64) NOT NULL PRIMARY KEY,
|
||||
description json NOT NULL
|
||||
);
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
|
||||
|
||||
<property name="json" value="clob" dbms="h2"/>
|
||||
<property name="json" value="jsonb" dbms="postgresql"/>
|
||||
|
||||
<changeSet author="jakubpilimon" id="1.product_management-init">
|
||||
<sql>
|
||||
CREATE SCHEMA product_management
|
||||
</sql>
|
||||
|
||||
<createTable tableName="product_description" schemaName="product_management">
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="description" type="${json}">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -1,22 +0,0 @@
|
||||
--liquibase formatted sql
|
||||
|
||||
--changeset michaluk.michal:1.init
|
||||
CREATE SCHEMA production_planning;
|
||||
|
||||
CREATE TABLE production_planning.production_daily_output (
|
||||
id serial NOT NULL PRIMARY KEY,
|
||||
ref_no character varying(64) NOT NULL,
|
||||
"date" timestamp without time zone NOT NULL,
|
||||
output bigint NOT NULL,
|
||||
UNIQUE(ref_no, "date")
|
||||
);
|
||||
|
||||
CREATE TABLE production_planning.production_output (
|
||||
id serial NOT NULL PRIMARY KEY,
|
||||
ref_no character varying(64) NOT NULL,
|
||||
"start" timestamp without time zone NOT NULL,
|
||||
"end" timestamp without time zone NOT NULL,
|
||||
duration bigint NOT NULL,
|
||||
parts_per_minute integer NOT NULL,
|
||||
total bigint NOT NULL
|
||||
);
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
|
||||
|
||||
<property name="json" value="clob" dbms="h2"/>
|
||||
<property name="json" value="jsonb" dbms="postgresql"/>
|
||||
|
||||
<changeSet author="jakubpilimon" id="1.production_planning-init">
|
||||
<sql>
|
||||
CREATE SCHEMA production_planning
|
||||
</sql>
|
||||
|
||||
|
||||
<createTable tableName="production_daily_output" schemaName="production_planning">
|
||||
<column name="id" type="serial">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="date" type="timestamp">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="output" type="bigint">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
<addUniqueConstraint
|
||||
columnNames="ref_no, date"
|
||||
constraintName="pp_output_refno_date_unique"
|
||||
schemaName="production_planning"
|
||||
tableName="production_daily_output"/>
|
||||
|
||||
<createTable tableName="production_output" schemaName="production_planning">
|
||||
<column name="id" type="serial">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="start" type="timestamp">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="end" type="timestamp">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="duration" type="bigint">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="parts_per_minute" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="total" type="bigint">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -1,19 +0,0 @@
|
||||
--liquibase formatted sql
|
||||
|
||||
--changeset michaluk.michal:1.init
|
||||
CREATE SCHEMA shortages_prediction;
|
||||
|
||||
CREATE TABLE shortages_prediction.shortage (
|
||||
id serial NOT NULL PRIMARY KEY,
|
||||
version bigint NOT NULL,
|
||||
ref_no character varying(64) NOT NULL,
|
||||
shortages json NOT NULL,
|
||||
UNIQUE(ref_no)
|
||||
);
|
||||
|
||||
CREATE TABLE shortages_prediction.stock_forecast (
|
||||
ref_no character varying(64) NOT NULL PRIMARY KEY
|
||||
);
|
||||
|
||||
--changeset michaluk.michal:2.rename.shortages.column
|
||||
ALTER TABLE shortages_prediction.shortage RENAME shortages TO shortage;
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
|
||||
|
||||
<property name="json" value="clob" dbms="h2"/>
|
||||
<property name="json" value="jsonb" dbms="postgresql"/>
|
||||
|
||||
<changeSet author="jakubpilimon" id="1.shortages_prediction-init">
|
||||
<sql>
|
||||
CREATE SCHEMA shortages_prediction
|
||||
</sql>
|
||||
|
||||
<createTable tableName="shortage" schemaName="shortages_prediction">
|
||||
<column name="id" type="serial">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="version" type="bigint">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints unique="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="shortages" type="${json}">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
|
||||
<createTable tableName="stock_forecast" schemaName="shortages_prediction">
|
||||
<column name="ref_no" type="varchar(64)">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="jakubpilimon" id="2.rename.shortages.column">
|
||||
<renameColumn tableName="shortage" oldColumnName="shortages" newColumnName="shortage" schemaName="shortages_prediction"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
10
app-monolith/src/test/resources/application.properties
Normal file
10
app-monolith/src/test/resources/application.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
spring.datasource.driver-class-name=org.h2.Driver
|
||||
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=sa
|
||||
|
||||
spring.main.banner-mode=off
|
||||
spring.jpa.database=default
|
||||
spring.jpa.generate-ddl=false
|
||||
|
||||
liquibase.change-log=classpath:/schema/db.changelog.xml
|
||||
Reference in New Issue
Block a user