Skip to content
Permalink
Browse files
Fixed flyway migration scripts
  • Loading branch information
Izakey committed May 2, 2019
1 parent 3475cb1 commit 542ab4737dd3232cde6988fd73b06d6f969972b9
Showing 3 changed files with 14 additions and 74 deletions.
@@ -25,7 +25,6 @@ spring:
enabled: false
datasource:
driver-class-name: org.postgresql.Driver
platform: postgres
url: jdbc:postgresql://localhost:5432/seshat
username: postgres
password: postgres
@@ -17,71 +17,18 @@
-- under the License.
--

CREATE TABLE horus_offices (
id BIGINT NOT NULL,
parent_office_id BIGINT NULL,
identifier VARCHAR(32) NOT NULL,
a_name VARCHAR(256) NOT NULL,
description VARCHAR(2048) NULL,
created_by VARCHAR(32) NOT NULL,
created_on TIMESTAMP(3) NOT NULL,
last_modified_by VARCHAR(32) NULL,
last_modified_on TIMESTAMP(3) NULL,
CONSTRAINT office_pk
PRIMARY KEY (id),
CONSTRAINT office_identifier_uq
UNIQUE (identifier),
CONSTRAINT office_parent_fk
FOREIGN KEY (parent_office_id) REFERENCES horus_offices (id)
ON UPDATE RESTRICT
);
CREATE TABLE IF NOT EXISTS horus_offices ( id BIGINT NOT NULL, parent_office_id BIGINT NULL, identifier VARCHAR(32) NOT NULL,a_name VARCHAR(256) NOT NULL, description VARCHAR(2048) NULL, created_by VARCHAR(32) NOT NULL, created_on TIMESTAMP(3) NOT NULL, last_modified_by VARCHAR(32) NULL, last_modified_on TIMESTAMP(3) NULL,
CONSTRAINT office_pk PRIMARY KEY (id), CONSTRAINT office_identifier_uq UNIQUE (identifier),CONSTRAINT office_parent_fk FOREIGN KEY (parent_office_id) REFERENCES horus_offices (id) ON UPDATE RESTRICT );

CREATE TABLE horus_addresses (
id BIGINT NOT NULL,
office_id BIGINT NOT NULL,
street VARCHAR(256) NOT NULL,
city VARCHAR(256) NOT NULL,
region VARCHAR(256) NULL,
postal_code VARCHAR(32) NULL,
country_code VARCHAR(2) NOT NULL,
country VARCHAR(256) NOT NULL,
CONSTRAINT address_pk
PRIMARY KEY (id),
CONSTRAINT address_office_fk
FOREIGN KEY (office_id) REFERENCES horus_offices (id)
ON UPDATE RESTRICT
);
CREATE TABLE IF NOT EXISTS horus_addresses ( id BIGINT NOT NULL, office_id BIGINT NOT NULL, street VARCHAR(256) NOT NULL, city VARCHAR(256) NOT NULL,region VARCHAR(256) NULL, postal_code VARCHAR(32) NULL, country_code VARCHAR(2) NOT NULL, country VARCHAR(256) NOT NULL,
CONSTRAINT address_pk PRIMARY KEY (id),
CONSTRAINT address_office_fk FOREIGN KEY (office_id) REFERENCES horus_offices (id) ON UPDATE RESTRICT);

CREATE TABLE horus_employees (
id BIGINT NOT NULL,
identifier VARCHAR(32) NOT NULL,
given_name VARCHAR(256) NULL,
middle_name VARCHAR(256) NULL,
surname VARCHAR(256) NULL,
assigned_office_id BIGINT NULL,
created_by VARCHAR(32) NOT NULL,
created_on TIMESTAMP(3) NOT NULL,
last_modified_by VARCHAR(32) NULL,
last_modified_on TIMESTAMP(3) NULL,
CONSTRAINT employee_pk
PRIMARY KEY (id),
CONSTRAINT employee_identifier_uq
UNIQUE (identifier),
CONSTRAINT employee_office_fk
FOREIGN KEY (assigned_office_id) REFERENCES horus_offices (id)
ON UPDATE RESTRICT
);
CREATE TABLE IF NOT EXISTS horus_employees ( id BIGINT NOT NULL, identifier VARCHAR(32) NOT NULL,given_name VARCHAR(256) NULL, middle_name VARCHAR(256) NULL,surname VARCHAR(256) NULL, assigned_office_id BIGINT NULL, created_by VARCHAR(32) NOT NULL,created_on TIMESTAMP(3) NOT NULL,last_modified_by VARCHAR(32) NULL,last_modified_on TIMESTAMP(3) NULL,
CONSTRAINT employee_pk PRIMARY KEY (id),
CONSTRAINT employee_identifier_uq UNIQUE (identifier),
CONSTRAINT employee_office_fk FOREIGN KEY (assigned_office_id) REFERENCES horus_offices (id) ON UPDATE RESTRICT);

CREATE TABLE horus_contact_details (
id BIGINT NOT NULL,
employee_id BIGINT NOT NULL,
a_type VARCHAR(256) NOT NULL,
a_group VARCHAR(256) NOT NULL,
a_value VARCHAR(256) NOT NULL,
preference_level TINYINT NULL,
CONSTRAINT contact_detail_pk
PRIMARY KEY (id),
CONSTRAINT contact_detail_employee_fk
FOREIGN KEY (employee_id) REFERENCES horus_employees (id)
ON UPDATE RESTRICT
);
CREATE TABLE horus_contact_details ( id BIGINT NOT NULL, employee_id BIGINT NOT NULL, a_type VARCHAR(256) NOT NULL, a_group VARCHAR(256) NOT NULL,a_value VARCHAR(256) NOT NULL, preference_level INT NULL,
CONSTRAINT contact_detail_pk PRIMARY KEY (id),
CONSTRAINT contact_detail_employee_fk FOREIGN KEY (employee_id) REFERENCES horus_employees (id) ON UPDATE RESTRICT);
@@ -17,11 +17,5 @@
-- under the License.
--

CREATE TABLE horus_external_references (
id BIGINT NOT NULL,
office_identifier VARCHAR(32) NOT NULL,
a_type VARCHAR(32) NULL,
a_state VARCHAR(256) NULL,
CONSTRAINT external_references_pk PRIMARY KEY (id),
CONSTRAINT external_references_uq UNIQUE (office_identifier, a_type)
);
CREATE TABLE IF NOT EXISTS horus_external_references ( id BIGINT NOT NULL, office_identifier VARCHAR(32) NOT NULL, a_type VARCHAR(32) NULL, a_state VARCHAR(256) NULL, CONSTRAINT external_references_pk PRIMARY KEY (id),
CONSTRAINT external_references_uq UNIQUE (office_identifier, a_type));

0 comments on commit 542ab47

Please sign in to comment.