Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
DROP TABLE m_org_closure; | ||
|
||
DROP TABLE IF EXISTS m_org_incorrect; | ||
|
||
CREATE TABLE m_org_closure ( | ||
descendant_oid VARCHAR(36) NOT NULL, | ||
ancestor_oid VARCHAR(36) NOT NULL, | ||
val INTEGER NOT NULL, | ||
PRIMARY KEY (descendant_oid, ancestor_oid) | ||
); | ||
|
||
CREATE INDEX iDescendant ON m_org_closure (descendant_oid); | ||
|
||
CREATE INDEX iAncestor ON m_org_closure (ancestor_oid); | ||
|
||
ALTER TABLE m_org_closure | ||
ADD CONSTRAINT fk_ancestor | ||
FOREIGN KEY (ancestor_oid) | ||
REFERENCES m_object; | ||
|
||
ALTER TABLE m_org_closure | ||
ADD CONSTRAINT fk_descendant | ||
FOREIGN KEY (descendant_oid) | ||
REFERENCES m_object; |
33 changes: 33 additions & 0 deletions
33
config/sql/midpoint/3.0/mysql/mysql-3.0-closure-upgrade.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
DROP TABLE m_org_closure; | ||
|
||
drop table if exists m_org_incorrect; | ||
|
||
-- | ||
-- Note: if getting | ||
-- "[HY000][150] Create table 'midpoint/#sql-7ec_8' with foreign key constraint failed. | ||
-- There is no index in the referenced table where the referenced columns appear as the first columns." | ||
-- then check the character set/collation compatibility between ancestor_oid/descendant_oid and m_object(oid). | ||
-- E.g. try to remove "DEFAULT CHARACTER SET utf8 COLLATE utf8_bin" from definition; or add the same to m_object. | ||
-- | ||
|
||
CREATE TABLE m_org_closure ( | ||
descendant_oid VARCHAR(36) NOT NULL, | ||
ancestor_oid VARCHAR(36) NOT NULL , | ||
val INTEGER NOT NULL , | ||
PRIMARY KEY (descendant_oid, ancestor_oid) | ||
) | ||
DEFAULT CHARACTER SET utf8 | ||
COLLATE utf8_bin | ||
ENGINE =InnoDB; | ||
|
||
ALTER TABLE m_org_closure | ||
ADD INDEX fk_ancestor (ancestor_oid), | ||
ADD CONSTRAINT fk_ancestor | ||
FOREIGN KEY (ancestor_oid) | ||
REFERENCES m_object (oid); | ||
|
||
ALTER TABLE m_org_closure | ||
ADD INDEX fk_descendant (descendant_oid), | ||
ADD CONSTRAINT fk_descendant | ||
FOREIGN KEY (descendant_oid) | ||
REFERENCES m_object (oid); |
48 changes: 48 additions & 0 deletions
48
config/sql/midpoint/3.0/oracle/oracle-3.0-closure-upgrade.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
DROP TABLE m_org_closure; | ||
|
||
BEGIN | ||
EXECUTE IMMEDIATE 'DROP TABLE m_org_incorrect'; | ||
EXCEPTION | ||
WHEN OTHERS THEN | ||
IF SQLCODE != -942 THEN | ||
RAISE; | ||
END IF; | ||
END; | ||
|
||
CREATE TABLE m_org_closure ( | ||
descendant_oid VARCHAR2(36 CHAR) NOT NULL, | ||
ancestor_oid VARCHAR2(36 CHAR) NOT NULL, | ||
val NUMBER(10, 0) NOT NULL, | ||
PRIMARY KEY (descendant_oid, ancestor_oid) | ||
) INITRANS 30; | ||
|
||
BEGIN | ||
EXECUTE IMMEDIATE 'DROP TABLE m_org_closure_temp_delta'; | ||
EXCEPTION | ||
WHEN OTHERS THEN | ||
IF SQLCODE != -942 THEN | ||
RAISE; | ||
END IF; | ||
END; | ||
|
||
CREATE GLOBAL TEMPORARY TABLE m_org_closure_temp_delta ( | ||
descendant_oid VARCHAR2(36 CHAR) NOT NULL, | ||
ancestor_oid VARCHAR2(36 CHAR) NOT NULL, | ||
val NUMBER (10, 0) NOT NULL, | ||
PRIMARY KEY (descendant_oid, ancestor_oid) | ||
) ON COMMIT DELETE ROWS; | ||
|
||
CREATE INDEX iAncestor ON m_org_closure (ancestor_oid) INITRANS 30; | ||
|
||
CREATE INDEX iDescendant ON m_org_closure (descendant_oid) INITRANS 30; | ||
|
||
ALTER TABLE m_org_closure | ||
ADD CONSTRAINT fk_ancestor | ||
FOREIGN KEY (ancestor_oid) | ||
REFERENCES m_object; | ||
|
||
ALTER TABLE m_org_closure | ||
ADD CONSTRAINT fk_descendant | ||
FOREIGN KEY (descendant_oid) | ||
REFERENCES m_object; | ||
|
24 changes: 24 additions & 0 deletions
24
config/sql/midpoint/3.0/postgresql/postgresql-3.0-closure-upgrade.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
DROP TABLE m_org_closure; | ||
|
||
DROP TABLE IF EXISTS m_org_incorrect; | ||
|
||
CREATE TABLE m_org_closure ( | ||
descendant_oid VARCHAR(36) NOT NULL, | ||
ancestor_oid VARCHAR(36) NOT NULL, | ||
val INT4 NOT NULL, | ||
PRIMARY KEY (descendant_oid, ancestor_oid) | ||
); | ||
|
||
CREATE INDEX iAncestor ON m_org_closure (ancestor_oid); | ||
|
||
CREATE INDEX iDescendant ON m_org_closure (descendant_oid); | ||
|
||
ALTER TABLE m_org_closure | ||
ADD CONSTRAINT fk_ancestor | ||
FOREIGN KEY (ancestor_oid) | ||
REFERENCES m_object; | ||
|
||
ALTER TABLE m_org_closure | ||
ADD CONSTRAINT fk_descendant | ||
FOREIGN KEY (descendant_oid) | ||
REFERENCES m_object; |
25 changes: 25 additions & 0 deletions
25
config/sql/midpoint/3.0/sqlserver/sqlserver-3.0-closure-upgrade.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
DROP TABLE m_org_closure; | ||
|
||
IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'm_org_incorrect') | ||
DROP TABLE m_org_incorrect; | ||
|
||
CREATE TABLE m_org_closure ( | ||
descendant_oid NVARCHAR(36) COLLATE database_default NOT NULL, | ||
ancestor_oid NVARCHAR(36) COLLATE database_default NOT NULL, | ||
val INT NOT NULL, | ||
PRIMARY KEY (descendant_oid, ancestor_oid) | ||
); | ||
|
||
CREATE INDEX iAncestor ON m_org_closure (ancestor_oid); | ||
|
||
CREATE INDEX iDescendant ON m_org_closure (descendant_oid); | ||
|
||
ALTER TABLE m_org_closure | ||
ADD CONSTRAINT fk_ancestor | ||
FOREIGN KEY (ancestor_oid) | ||
REFERENCES m_object; | ||
|
||
ALTER TABLE m_org_closure | ||
ADD CONSTRAINT fk_descendant | ||
FOREIGN KEY (descendant_oid) | ||
REFERENCES m_object; |