Skip to content

Commit

Permalink
MID-2133 updated SQL scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Apr 4, 2015
1 parent d57ccc1 commit 7023ef8
Show file tree
Hide file tree
Showing 9 changed files with 426 additions and 37 deletions.
65 changes: 53 additions & 12 deletions config/sql/midpoint/3.1.1/h2/h2-3.1.1.sql
Expand Up @@ -6,7 +6,7 @@ CREATE TABLE m_abstract_role (
);

CREATE TABLE m_assignment (
id INTEGER NOT NULL,
id INTEGER NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
administrativeStatus INTEGER,
archiveTimestamp TIMESTAMP,
Expand Down Expand Up @@ -41,9 +41,21 @@ CREATE TABLE m_assignment (
PRIMARY KEY (id, owner_oid)
);

CREATE TABLE m_assignment_ext_boolean (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
booleanValue BOOLEAN NOT NULL,
extensionType INTEGER,
dynamicDef BOOLEAN,
eType VARCHAR(157),
valueType INTEGER,
PRIMARY KEY (eName, anyContainer_owner_id, anyContainer_owner_owner_oid, booleanValue)
);

CREATE TABLE m_assignment_ext_date (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
dateValue TIMESTAMP NOT NULL,
extensionType INTEGER,
Expand All @@ -55,7 +67,7 @@ CREATE TABLE m_assignment_ext_date (

CREATE TABLE m_assignment_ext_long (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
longValue BIGINT NOT NULL,
extensionType INTEGER,
Expand All @@ -67,7 +79,7 @@ CREATE TABLE m_assignment_ext_long (

CREATE TABLE m_assignment_ext_poly (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
orig VARCHAR(255) NOT NULL,
extensionType INTEGER,
Expand All @@ -80,7 +92,7 @@ CREATE TABLE m_assignment_ext_poly (

CREATE TABLE m_assignment_ext_reference (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
targetoid VARCHAR(36) NOT NULL,
extensionType INTEGER,
Expand All @@ -94,7 +106,7 @@ CREATE TABLE m_assignment_ext_reference (

CREATE TABLE m_assignment_ext_string (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
stringValue VARCHAR(255) NOT NULL,
extensionType INTEGER,
Expand All @@ -105,8 +117,9 @@ CREATE TABLE m_assignment_ext_string (
);

CREATE TABLE m_assignment_extension (
owner_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL,
owner_owner_oid VARCHAR(36) NOT NULL,
booleansCount SMALLINT,
datesCount SMALLINT,
longsCount SMALLINT,
polysCount SMALLINT,
Expand All @@ -116,7 +129,7 @@ CREATE TABLE m_assignment_extension (
);

CREATE TABLE m_assignment_reference (
owner_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL,
owner_owner_oid VARCHAR(36) NOT NULL,
reference_type INTEGER NOT NULL,
relation VARCHAR(157) NOT NULL,
Expand Down Expand Up @@ -190,7 +203,7 @@ CREATE TABLE m_connector_target_system (
);

CREATE TABLE m_exclusion (
id INTEGER NOT NULL,
id INTEGER NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
policy INTEGER,
targetRef_relation VARCHAR(157),
Expand Down Expand Up @@ -230,7 +243,7 @@ CREATE TABLE m_lookup_table (
);

CREATE TABLE m_lookup_table_row (
id INTEGER NOT NULL,
id INTEGER NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
row_key VARCHAR(255),
label_norm VARCHAR(255),
Expand All @@ -250,6 +263,7 @@ CREATE TABLE m_node (

CREATE TABLE m_object (
oid VARCHAR(36) NOT NULL,
booleansCount SMALLINT,
createChannel VARCHAR(255),
createTimestamp TIMESTAMP,
creatorRef_relation VARCHAR(157),
Expand All @@ -276,6 +290,17 @@ CREATE TABLE m_object (
PRIMARY KEY (oid)
);

CREATE TABLE m_object_ext_boolean (
eName VARCHAR(157) NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
ownerType INTEGER NOT NULL,
booleanValue BOOLEAN NOT NULL,
dynamicDef BOOLEAN,
eType VARCHAR(157),
valueType INTEGER,
PRIMARY KEY (eName, owner_oid, ownerType, booleanValue)
);

CREATE TABLE m_object_ext_date (
eName VARCHAR(157) NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
Expand Down Expand Up @@ -488,7 +513,7 @@ CREATE TABLE m_task_dependent (
);

CREATE TABLE m_trigger (
id INTEGER NOT NULL,
id INTEGER NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
handlerUri VARCHAR(255),
timestampValue TIMESTAMP,
Expand Down Expand Up @@ -565,6 +590,8 @@ CREATE INDEX iAssignmentAdministrative ON m_assignment (administrativeStatus);

CREATE INDEX iAssignmentEffective ON m_assignment (effectiveStatus);

CREATE INDEX iAExtensionBoolean ON m_assignment_ext_boolean (extensionType, eName, booleanValue);

CREATE INDEX iAExtensionDate ON m_assignment_ext_date (extensionType, eName, dateValue);

CREATE INDEX iAExtensionLong ON m_assignment_ext_long (extensionType, eName, longValue);
Expand All @@ -591,7 +618,7 @@ ALTER TABLE m_lookup_table
ADD CONSTRAINT uc_lookup_name UNIQUE (name_norm);

ALTER TABLE m_lookup_table_row
ADD CONSTRAINT uc_row_key unique (row_key);
ADD CONSTRAINT uc_row_key UNIQUE (row_key);

ALTER TABLE m_node
ADD CONSTRAINT uc_node_name UNIQUE (name_norm);
Expand All @@ -604,6 +631,10 @@ CREATE INDEX iObjectTypeClass ON m_object (objectTypeClass);

CREATE INDEX iObjectCreateTimestamp ON m_object (createTimestamp);

CREATE INDEX iExtensionBoolean ON m_object_ext_boolean (ownerType, eName, booleanValue);

CREATE INDEX iExtensionBooleanDef ON m_object_ext_boolean (owner_oid, ownerType);

CREATE INDEX iExtensionDate ON m_object_ext_date (ownerType, eName, dateValue);

CREATE INDEX iExtensionDateDef ON m_object_ext_date (owner_oid, ownerType);
Expand Down Expand Up @@ -691,6 +722,11 @@ ADD CONSTRAINT fk_assignment_owner
FOREIGN KEY (owner_oid)
REFERENCES m_object;

ALTER TABLE m_assignment_ext_boolean
ADD CONSTRAINT fk_assignment_ext_boolean
FOREIGN KEY (anyContainer_owner_id, anyContainer_owner_owner_oid)
REFERENCES m_assignment_extension;

ALTER TABLE m_assignment_ext_date
ADD CONSTRAINT fk_assignment_ext_date
FOREIGN KEY (anyContainer_owner_id, anyContainer_owner_owner_oid)
Expand Down Expand Up @@ -771,6 +807,11 @@ ADD CONSTRAINT fk_node
FOREIGN KEY (oid)
REFERENCES m_object;

ALTER TABLE m_object_ext_boolean
ADD CONSTRAINT fk_object_ext_boolean
FOREIGN KEY (owner_oid)
REFERENCES m_object;

ALTER TABLE m_object_ext_date
ADD CONSTRAINT fk_object_ext_date
FOREIGN KEY (owner_oid)
Expand Down
71 changes: 59 additions & 12 deletions config/sql/midpoint/3.1.1/mysql/mysql-3.1.1.sql
Expand Up @@ -22,7 +22,7 @@ CREATE TABLE m_abstract_role (
ENGINE = InnoDB;

CREATE TABLE m_assignment (
id INTEGER NOT NULL,
id INTEGER NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
administrativeStatus INTEGER,
archiveTimestamp DATETIME(6),
Expand Down Expand Up @@ -60,9 +60,24 @@ CREATE TABLE m_assignment (
COLLATE utf8_bin
ENGINE = InnoDB;

CREATE TABLE m_assignment_ext_boolean (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
booleanValue BIT NOT NULL,
extensionType INTEGER,
dynamicDef BIT,
eType VARCHAR(157),
valueType INTEGER,
PRIMARY KEY (eName, anyContainer_owner_id, anyContainer_owner_owner_oid, booleanValue)
)
DEFAULT CHARACTER SET utf8
COLLATE utf8_bin
ENGINE = InnoDB;

CREATE TABLE m_assignment_ext_date (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
dateValue DATETIME(6) NOT NULL,
extensionType INTEGER,
Expand All @@ -77,7 +92,7 @@ CREATE TABLE m_assignment_ext_date (

CREATE TABLE m_assignment_ext_long (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
longValue BIGINT NOT NULL,
extensionType INTEGER,
Expand All @@ -92,7 +107,7 @@ CREATE TABLE m_assignment_ext_long (

CREATE TABLE m_assignment_ext_poly (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
orig VARCHAR(255) NOT NULL,
extensionType INTEGER,
Expand All @@ -108,7 +123,7 @@ CREATE TABLE m_assignment_ext_poly (

CREATE TABLE m_assignment_ext_reference (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
targetoid VARCHAR(36) NOT NULL,
extensionType INTEGER,
Expand All @@ -125,7 +140,7 @@ CREATE TABLE m_assignment_ext_reference (

CREATE TABLE m_assignment_ext_string (
eName VARCHAR(157) NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_id INTEGER NOT NULL,
anyContainer_owner_owner_oid VARCHAR(36) NOT NULL,
stringValue VARCHAR(255) NOT NULL,
extensionType INTEGER,
Expand All @@ -139,8 +154,9 @@ CREATE TABLE m_assignment_ext_string (
ENGINE = InnoDB;

CREATE TABLE m_assignment_extension (
owner_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL,
owner_owner_oid VARCHAR(36) NOT NULL,
booleansCount SMALLINT,
datesCount SMALLINT,
longsCount SMALLINT,
polysCount SMALLINT,
Expand All @@ -153,7 +169,7 @@ CREATE TABLE m_assignment_extension (
ENGINE = InnoDB;

CREATE TABLE m_assignment_reference (
owner_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL,
owner_owner_oid VARCHAR(36) NOT NULL,
reference_type INTEGER NOT NULL,
relation VARCHAR(157) NOT NULL,
Expand Down Expand Up @@ -245,7 +261,7 @@ CREATE TABLE m_connector_target_system (
ENGINE = InnoDB;

CREATE TABLE m_exclusion (
id INTEGER NOT NULL,
id INTEGER NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
policy INTEGER,
targetRef_relation VARCHAR(157),
Expand Down Expand Up @@ -297,12 +313,12 @@ CREATE TABLE m_lookup_table (
ENGINE = InnoDB;

CREATE TABLE m_lookup_table_row (
id INTEGER NOT NULL,
id INTEGER NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
row_key VARCHAR(255),
label_norm VARCHAR(255),
label_orig VARCHAR(255),
lastChangeTimestamp DATETIME,
lastChangeTimestamp DATETIME(6),
row_value VARCHAR(255),
PRIMARY KEY (id, owner_oid)
)
Expand All @@ -323,6 +339,7 @@ CREATE TABLE m_node (

CREATE TABLE m_object (
oid VARCHAR(36) NOT NULL,
booleansCount SMALLINT,
createChannel VARCHAR(255),
createTimestamp DATETIME(6),
creatorRef_relation VARCHAR(157),
Expand Down Expand Up @@ -352,6 +369,20 @@ CREATE TABLE m_object (
COLLATE utf8_bin
ENGINE = InnoDB;

CREATE TABLE m_object_ext_boolean (
eName VARCHAR(157) NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
ownerType INTEGER NOT NULL,
booleanValue BIT NOT NULL,
dynamicDef BIT,
eType VARCHAR(157),
valueType INTEGER,
PRIMARY KEY (eName, owner_oid, ownerType, booleanValue)
)
DEFAULT CHARACTER SET utf8
COLLATE utf8_bin
ENGINE = InnoDB;

CREATE TABLE m_object_ext_date (
eName VARCHAR(157) NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
Expand Down Expand Up @@ -621,7 +652,7 @@ CREATE TABLE m_task_dependent (
ENGINE = InnoDB;

CREATE TABLE m_trigger (
id INTEGER NOT NULL,
id INTEGER NOT NULL,
owner_oid VARCHAR(36) NOT NULL,
handlerUri VARCHAR(255),
timestampValue DATETIME(6),
Expand Down Expand Up @@ -719,6 +750,8 @@ CREATE INDEX iAssignmentAdministrative ON m_assignment (administrativeStatus);

CREATE INDEX iAssignmentEffective ON m_assignment (effectiveStatus);

CREATE INDEX iAExtensionBoolean ON m_assignment_ext_boolean (extensionType, eName, booleanValue);

CREATE INDEX iAExtensionDate ON m_assignment_ext_date (extensionType, eName, dateValue);

CREATE INDEX iAExtensionLong ON m_assignment_ext_long (extensionType, eName, longValue);
Expand Down Expand Up @@ -758,6 +791,10 @@ CREATE INDEX iObjectTypeClass ON m_object (objectTypeClass);

CREATE INDEX iObjectCreateTimestamp ON m_object (createTimestamp);

CREATE INDEX iExtensionBoolean ON m_object_ext_boolean (ownerType, eName, booleanValue);

CREATE INDEX iExtensionBooleanDef ON m_object_ext_boolean (owner_oid, ownerType);

CREATE INDEX iExtensionDate ON m_object_ext_date (ownerType, eName, dateValue);

CREATE INDEX iExtensionDateDef ON m_object_ext_date (owner_oid, ownerType);
Expand Down Expand Up @@ -847,6 +884,11 @@ ADD CONSTRAINT fk_assignment_owner
FOREIGN KEY (owner_oid)
REFERENCES m_object (oid);

ALTER TABLE m_assignment_ext_boolean
ADD CONSTRAINT fk_assignment_ext_boolean
FOREIGN KEY (anyContainer_owner_id, anyContainer_owner_owner_oid)
REFERENCES m_assignment_extension (owner_id, owner_owner_oid);

ALTER TABLE m_assignment_ext_date
ADD CONSTRAINT fk_assignment_ext_date
FOREIGN KEY (anyContainer_owner_id, anyContainer_owner_owner_oid)
Expand Down Expand Up @@ -927,6 +969,11 @@ ADD CONSTRAINT fk_node
FOREIGN KEY (oid)
REFERENCES m_object (oid);

ALTER TABLE m_object_ext_boolean
ADD CONSTRAINT fk_object_ext_boolean
FOREIGN KEY (owner_oid)
REFERENCES m_object (oid);

ALTER TABLE m_object_ext_date
ADD CONSTRAINT fk_object_ext_date
FOREIGN KEY (owner_oid)
Expand Down

0 comments on commit 7023ef8

Please sign in to comment.