diff --git a/docs/manual/src/docs/asciidoc/_includes/appendix/database-schema.adoc b/docs/manual/src/docs/asciidoc/_includes/appendix/database-schema.adoc index ba4c1ed410..84707d0fb2 100644 --- a/docs/manual/src/docs/asciidoc/_includes/appendix/database-schema.adoc +++ b/docs/manual/src/docs/asciidoc/_includes/appendix/database-schema.adoc @@ -28,6 +28,24 @@ create table authorities ( create unique index ix_auth_username on authorities (username,authority); ---- +=== For Oracle database +[source] +---- +CREATE TABLE USERS ( + USERNAME NVARCHAR2(128) NOT NULL PRIMARY KEY, + PASSWORD NVARCHAR2(128) NOT NULL, + ENABLED CHAR(1) CHECK (ENABLED IN ('Y','N') ) NOT NULL +); + + +CREATE TABLE AUTHORITIES ( + USERNAME NVARCHAR2(128) NOT NULL, + AUTHORITY NVARCHAR2(128) NOT NULL +); +ALTER TABLE AUTHORITIES ADD CONSTRAINT AUTHORITIES_UNIQUE UNIQUE (USERNAME, AUTHORITY); +ALTER TABLE AUTHORITIES ADD CONSTRAINT AUTHORITIES_FK1 FOREIGN KEY (USERNAME) REFERENCES USERS (USERNAME) ENABLE; +---- + ==== Group Authorities Spring Security 2.0 introduced support for group authorities in `JdbcDaoImpl`. The table structure if groups are enabled is as follows. @@ -282,71 +300,66 @@ CREATE TABLE acl_entry ( ==== Oracle Database [source,ddl] ---- -CREATE TABLE acl_sid ( - id NUMBER(38) NOT NULL PRIMARY KEY, - principal NUMBER(1) NOT NULL CHECK (principal in (0, 1)), - sid NVARCHAR2(100) NOT NULL, - CONSTRAINT unique_acl_sid UNIQUE (sid, principal) +CREATE TABLE ACL_SID ( + ID NUMBER(18) PRIMARY KEY, + PRINCIPAL NUMBER(1) NOT NULL CHECK (PRINCIPAL IN (0, 1 )), + SID NVARCHAR2(128) NOT NULL, + CONSTRAINT ACL_SID_UNIQUE UNIQUE (SID, PRINCIPAL) ); -CREATE SEQUENCE acl_sid_sequence START WITH 1 INCREMENT BY 1 NOMAXVALUE; -CREATE OR REPLACE TRIGGER acl_sid_id_trigger - BEFORE INSERT ON acl_sid - FOR EACH ROW +CREATE SEQUENCE ACL_SID_SQ START WITH 1 INCREMENT BY 1 NOMAXVALUE; +CREATE OR REPLACE TRIGGER ACL_SID_SQ_TR BEFORE INSERT ON ACL_SID FOR EACH ROW BEGIN - SELECT acl_sid_sequence.nextval INTO :new.id FROM dual; + SELECT ACL_SID_SQ.NEXTVAL INTO :NEW.ID FROM DUAL; END; -CREATE TABLE acl_class ( - id NUMBER(38) NOT NULL PRIMARY KEY, - class NVARCHAR2(100) NOT NULL, - CONSTRAINT uk_acl_class UNIQUE (class) + +CREATE TABLE ACL_CLASS ( + ID NUMBER(18) PRIMARY KEY, + CLASS NVARCHAR2(128) NOT NULL, + CONSTRAINT ACL_CLASS_UNIQUE UNIQUE (CLASS) ); -CREATE SEQUENCE acl_class_sequence START WITH 1 INCREMENT BY 1 NOMAXVALUE; -CREATE OR REPLACE TRIGGER acl_class_id_trigger - BEFORE INSERT ON acl_class - FOR EACH ROW +CREATE SEQUENCE ACL_CLASS_SQ START WITH 1 INCREMENT BY 1 NOMAXVALUE; +CREATE OR REPLACE TRIGGER ACL_CLASS_ID_TR BEFORE INSERT ON ACL_CLASS FOR EACH ROW BEGIN - SELECT acl_class_sequence.nextval INTO :new.id FROM dual; + SELECT ACL_CLASS_SQ.NEXTVAL INTO :NEW.ID FROM DUAL; END; -CREATE TABLE acl_object_identity ( - id NUMBER(38) NOT NULL PRIMARY KEY, - object_id_class NUMBER(38) NOT NULL, - object_id_identity NVARCHAR2(36) NOT NULL, - parent_object NUMBER(38), - owner_sid NUMBER(38), - entries_inheriting NUMBER(1) NOT NULL CHECK (entries_inheriting in (0, 1)), - CONSTRAINT uk_acl_object_identity UNIQUE (object_id_class, object_id_identity), - CONSTRAINT fk_acl_object_identity_parent FOREIGN KEY (parent_object) REFERENCES acl_object_identity (id), - CONSTRAINT fk_acl_object_identity_class FOREIGN KEY (object_id_class) REFERENCES acl_class (id), - CONSTRAINT fk_acl_object_identity_owner FOREIGN KEY (owner_sid) REFERENCES acl_sid (id) + +CREATE TABLE ACL_OBJECT_IDENTITY( + ID NUMBER(18) PRIMARY KEY, + OBJECT_ID_CLASS NUMBER(18) NOT NULL, + OBJECT_ID_IDENTITY NVARCHAR2(64) NOT NULL, + PARENT_OBJECT NUMBER(18), + OWNER_SID NUMBER(18), + ENTRIES_INHERITING NUMBER(1) NOT NULL CHECK (ENTRIES_INHERITING IN (0, 1)), + CONSTRAINT ACL_OBJECT_IDENTITY_UNIQUE UNIQUE (OBJECT_ID_CLASS, OBJECT_ID_IDENTITY), + CONSTRAINT ACL_OBJECT_IDENTITY_PARENT_FK FOREIGN KEY (PARENT_OBJECT) REFERENCES ACL_OBJECT_IDENTITY(ID), + CONSTRAINT ACL_OBJECT_IDENTITY_CLASS_FK FOREIGN KEY (OBJECT_ID_CLASS) REFERENCES ACL_CLASS(ID), + CONSTRAINT ACL_OBJECT_IDENTITY_OWNER_FK FOREIGN KEY (OWNER_SID) REFERENCES ACL_SID(ID) ); -CREATE SEQUENCE acl_object_identity_sequence START WITH 1 INCREMENT BY 1 NOMAXVALUE; -CREATE OR REPLACE TRIGGER acl_object_identity_id_trigger - BEFORE INSERT ON acl_object_identity - FOR EACH ROW +CREATE SEQUENCE ACL_OBJECT_IDENTITY_SQ START WITH 1 INCREMENT BY 1 NOMAXVALUE; +CREATE OR REPLACE TRIGGER ACL_OBJECT_IDENTITY_ID_TR BEFORE INSERT ON ACL_OBJECT_IDENTITY FOR EACH ROW BEGIN - SELECT acl_object_identity_sequence.nextval INTO :new.id FROM dual; + SELECT ACL_OBJECT_IDENTITY_SQ.NEXTVAL INTO :NEW.ID FROM DUAL; END; -CREATE TABLE acl_entry ( - id NUMBER(38) NOT NULL PRIMARY KEY, - acl_object_identity NUMBER(38) NOT NULL, - ace_order INTEGER NOT NULL, - sid NUMBER(38) NOT NULL, - mask INTEGER NOT NULL, - granting NUMBER(1) NOT NULL CHECK (granting in (0, 1)), - audit_success NUMBER(1) NOT NULL CHECK (audit_success in (0, 1)), - audit_failure NUMBER(1) NOT NULL CHECK (audit_failure in (0, 1)), - CONSTRAINT unique_acl_entry UNIQUE (acl_object_identity, ace_order), - CONSTRAINT fk_acl_entry_object FOREIGN KEY (acl_object_identity) REFERENCES acl_object_identity (id), - CONSTRAINT fk_acl_entry_acl FOREIGN KEY (sid) REFERENCES acl_sid (id) + +CREATE TABLE ACL_ENTRY ( + ID NUMBER(18) NOT NULL PRIMARY KEY, + ACL_OBJECT_IDENTITY NUMBER(18) NOT NULL, + ACE_ORDER INTEGER NOT NULL, + SID NUMBER(18) NOT NULL, + MASK INTEGER NOT NULL, + GRANTING NUMBER(1) NOT NULL CHECK (GRANTING IN (0, 1)), + AUDIT_SUCCESS NUMBER(1) NOT NULL CHECK (AUDIT_SUCCESS IN (0, 1)), + AUDIT_FAILURE NUMBER(1) NOT NULL CHECK (AUDIT_FAILURE IN (0, 1)), + CONSTRAINT ACL_ENTRY_UNIQUE UNIQUE (ACL_OBJECT_IDENTITY, ACE_ORDER), + CONSTRAINT ACL_ENTRY_OBJECT_FK FOREIGN KEY (ACL_OBJECT_IDENTITY) REFERENCES ACL_OBJECT_IDENTITY (ID), + CONSTRAINT ACL_ENTRY_ACL_FK FOREIGN KEY (SID) REFERENCES ACL_SID(ID) ); -CREATE SEQUENCE acl_entry_sequence START WITH 1 INCREMENT BY 1 NOMAXVALUE; -CREATE OR REPLACE TRIGGER acl_entry_id_trigger - BEFORE INSERT ON acl_entry - FOR EACH ROW +CREATE SEQUENCE ACL_ENTRY_SQ START WITH 1 INCREMENT BY 1 NOMAXVALUE; +CREATE OR REPLACE TRIGGER ACL_ENTRY_ID_TRIGGER BEFORE INSERT ON ACL_ENTRY FOR EACH ROW BEGIN - SELECT acl_entry_sequence.nextval INTO :new.id FROM dual; + SELECT ACL_ENTRY_SQ.NEXTVAL INTO :NEW.ID FROM DUAL; END; ----