ALTER TABLE IDN_OAUTH2_SCOPE RENAME COLUMN NAME TO DISPLAY_NAME
/
ALTER TABLE IDN_OAUTH2_SCOPE RENAME COLUMN SCOPE_KEY TO NAME
/
ALTER TABLE IDN_OAUTH2_SCOPE DROP COLUMN ROLES
/
UPDATE IDN_OAUTH2_SCOPE SET TENANT_ID = -1 WHERE TENANT_ID = 0
/
ALTER TABLE IDN_OAUTH2_SCOPE ALTER COLUMN TENANT_ID SET DEFAULT -1
/
CALL SYSPROC.ADMIN_CMD('REORG TABLE IDN_OAUTH2_SCOPE')
/
BEGIN
 DECLARE const_name VARCHAR(128);
 DECLARE STMT VARCHAR(200);
 select CONSTNAME into const_name from SYSCAT.TABCONST WHERE TABNAME='IDN_OAUTH2_RESOURCE_SCOPE' AND TYPE = 'F';
 SET STMT = 'ALTER TABLE IDN_OAUTH2_RESOURCE_SCOPE DROP FOREIGN KEY ' ||  const_name;
 PREPARE S1 FROM STMT;
 EXECUTE S1;
END
/
ALTER TABLE IDN_OAUTH2_RESOURCE_SCOPE ADD FOREIGN KEY(SCOPE_ID) REFERENCES IDN_OAUTH2_SCOPE(SCOPE_ID) ON DELETE CASCADE
/
