Skip to content

Commit

Permalink
updated main and upgrade sql scripts for sql server.
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Feb 22, 2015
1 parent 4e7051c commit 2bc1a4d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
10 changes: 5 additions & 5 deletions config/sql/midpoint/3.1.1/sqlserver/sqlserver-3.1.1.sql
Expand Up @@ -116,13 +116,13 @@ CREATE TABLE m_assignment_extension (
);

CREATE TABLE m_assignment_reference (
reference_type INT NOT NULL,
owner_id SMALLINT NOT NULL,
owner_owner_oid NVARCHAR(36) COLLATE database_default NOT NULL,
reference_type INT NOT NULL,
relation NVARCHAR(157) COLLATE database_default NOT NULL,
targetOid NVARCHAR(36) COLLATE database_default NOT NULL,
containerType INT,
PRIMARY KEY (owner_id, owner_owner_oid, relation, targetOid)
PRIMARY KEY (owner_id, owner_owner_oid, reference_type, relation, targetOid)
);

CREATE TABLE m_audit_delta (
Expand Down Expand Up @@ -369,12 +369,12 @@ CREATE TABLE m_org_org_type (
);

CREATE TABLE m_reference (
reference_type INT NOT NULL,
owner_oid NVARCHAR(36) COLLATE database_default NOT NULL,
reference_type INT NOT NULL,
relation NVARCHAR(157) COLLATE database_default NOT NULL,
targetOid NVARCHAR(36) COLLATE database_default NOT NULL,
containerType INT,
PRIMARY KEY (owner_oid, relation, targetOid)
PRIMARY KEY (owner_oid, reference_type, relation, targetOid)
);

CREATE TABLE m_report (
Expand Down Expand Up @@ -758,7 +758,7 @@ FOREIGN KEY (oid)
REFERENCES m_object;

ALTER TABLE m_lookup_table_row
ADD CONSTRAINT fk_lookup_table
ADD CONSTRAINT fk_lookup_table_owner
FOREIGN KEY (owner_oid)
REFERENCES m_lookup_table;

Expand Down
Expand Up @@ -24,6 +24,19 @@ FOREIGN KEY (oid)
REFERENCES m_object;

ALTER TABLE m_lookup_table_row
ADD CONSTRAINT fk_lookup_table
ADD CONSTRAINT fk_lookup_table_owner
FOREIGN KEY (owner_oid)
REFERENCES m_lookup_table;
REFERENCES m_lookup_table;

declare @pkname varchar(255);
set @pkname = (SELECT name FROM sys.key_constraints WHERE type = 'PK' AND OBJECT_NAME(parent_object_id) = N'm_assignment_reference');

execute ('ALTER TABLE m_assignment_reference DROP CONSTRAINT ' + @pkname);
alter table m_assignment_reference add constraint PK_m_a_reference primary key clustered (owner_id, owner_owner_oid, reference_type, relation, targetOid);

set @pkname = (SELECT name FROM sys.key_constraints WHERE type = 'PK' AND OBJECT_NAME(parent_object_id) = N'm_reference');

execute ('ALTER TABLE m_reference DROP CONSTRAINT ' + @pkname);
alter table m_reference add constraint PK_m_reference primary key clustered (owner_oid, reference_type, relation, targetOid);
go

0 comments on commit 2bc1a4d

Please sign in to comment.