Hi IS Team,

I have been going through the IS 5.1.0 Beta DB Scripts and found following
in them.

CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR (
            .........
            FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE);

INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, *1*,
'samlsso');
INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, *1*,
'IDPProperties');
INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, *1*,
'passivests');

CREATE TABLE IF NOT EXISTS IDP_METADATA (
            ...........
            FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE);

INSERT INTO IDP_METADATA (IDP_ID, NAME, VALUE, DISPLAY_NAME, TENANT_ID)
VALUES (*1*, 'SessionIdleTimeout', '15', 'Session Idle Timeout', -1234);
INSERT INTO IDP_METADATA (IDP_ID, NAME, VALUE, DISPLAY_NAME, TENANT_ID)
VALUES (*1*, 'RememberMeTimeout', '20160', 'RememberMe Timeout', -1234);

CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR_PROPERTY (
            .............
            FOREIGN KEY (AUTHENTICATOR_ID) REFERENCES IDP_AUTHENTICATOR(ID)
ON DELETE CASCADE);

INSERT INTO  IDP_AUTHENTICATOR_PROPERTY (TENANT_ID, AUTHENTICATOR_ID,
PROPERTY_KEY,PROPERTY_VALUE, IS_SECRET ) VALUES (-1234, *1* ,
'IdPEntityId', 'localhost', '0');
INSERT INTO  IDP_AUTHENTICATOR_PROPERTY (TENANT_ID, AUTHENTICATOR_ID,
PROPERTY_KEY,PROPERTY_VALUE, IS_SECRET ) VALUES (-1234, *3* ,
'IdPEntityId', 'localhost', '0');


In above, when inserting the default records to the tables, for column
values like IDP_ID, AUTHENTICATOR_ID, it enters hard coded numbers. Which
means it relies on the underlying database table's sequence and assumes
that when running this script, the auto_increment columns start from 1
which may not true sometimes.

So I think it's better if we can avoid this practice and instead use inner
queries to obtain the particular column value. This won't be an overhead
and also avoids relying on the underlying sequence of the tables.

Thanks
TharinduE

-- 

Tharindu Edirisinghe
Software Engineer | WSO2 Inc
Identity Server Team
Blog : tharindue.blogspot.com
mobile : 408-714-8437
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to