Fixed broken scripts from schema change on system_scope

pull/1406/head
Angelo Kastroulis 2018-06-11 15:50:05 -04:00
parent 802e40ebc9
commit f56918982a
5 changed files with 34 additions and 40 deletions

View File

@ -10,13 +10,13 @@ START TRANSACTION;
-- Insert scope information into the temporary tables. -- Insert scope information into the temporary tables.
-- --
INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope) VALUES
('openid', 'log in using your identity', 'user', false, true, false, null), ('openid', 'log in using your identity', 'user', false, true),
('profile', 'basic profile information', 'list-alt', false, true, false, null), ('profile', 'basic profile information', 'list-alt', false, true),
('email', 'email address', 'envelope', false, true, false, null), ('email', 'email address', 'envelope', false, true),
('address', 'physical address', 'home', false, true, false, null), ('address', 'physical address', 'home', false, true),
('phone', 'telephone number', 'bell', false, true, false, null), ('phone', 'telephone number', 'bell', false, true),
('offline_access', 'offline access', 'time', false, false, false, null); ('offline_access', 'offline access', 'time', false, false);
-- --
-- Merge the temporary scopes safely into the database. This is a two-step process to keep scopes from being created on every startup with a persistent store. -- Merge the temporary scopes safely into the database. This is a two-step process to keep scopes from being created on every startup with a persistent store.

View File

@ -255,14 +255,11 @@ CREATE TABLE system_scope (
description VARCHAR2(4000), description VARCHAR2(4000),
icon VARCHAR2(256), icon VARCHAR2(256),
restricted NUMBER(1) DEFAULT 0 NOT NULL, restricted NUMBER(1) DEFAULT 0 NOT NULL,
default_scope NUMBER(1) DEFAULT 0 NOT NULL, default_scope NUMBER(1) DEFAULT 0 NOT NULL
structured NUMBER(1) DEFAULT 0 NOT NULL,
structured_param_description VARCHAR2(256),
CONSTRAINT system_scope_unique UNIQUE (scope), CONSTRAINT system_scope_unique UNIQUE (scope),
CONSTRAINT default_scope_check CHECK (default_scope in (1,0)), CONSTRAINT default_scope_check CHECK (default_scope in (1,0)),
CONSTRAINT restricted_check CHECK (restricted in (1,0)), CONSTRAINT restricted_check CHECK (restricted in (1,0))
CONSTRAINT structured_check CHECK (structured in (1,0))
); );
CREATE SEQUENCE system_scope_seq START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE; CREATE SEQUENCE system_scope_seq START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;

View File

@ -2,26 +2,25 @@
-- Insert scope information into the temporary tables. -- Insert scope information into the temporary tables.
-- --
INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope) VALUES
('openid', 'log in using your identity', 'user', 0, 1, 0, null); ('openid', 'log in using your identity', 'user', 0, 1);
INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope) VALUES
('profile', 'basic profile information', 'list-alt', 0, 1, 0, null); ('profile', 'basic profile information', 'list-alt', 0, 1);
INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope) VALUES
('email', 'email address', 'envelope', 0, 1, 0, null); ('email', 'email address', 'envelope', 0, 1);
INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope) VALUES
('address', 'physical address', 'home', 0, 1, 0, null); ('address', 'physical address', 'home', 0, 1);
INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope) VALUES
('phone', 'telephone number', 'bell', 0, 1, 0, null); ('phone', 'telephone number', 'bell', 0, 1, 0);
INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope) VALUES
('offline_access', 'offline access', 'time', 0, 0, 0, null); ('offline_access', 'offline access', 'time', 0, 0);
-- --
-- Merge the temporary scopes safely into the database. This is a two-step process to keep scopes from being created on every startup with a persistent store. -- Merge the temporary scopes safely into the database. This is a two-step process to keep scopes from being created on every startup with a persistent store.
-- --
MERGE INTO system_scope MERGE INTO system_scope
USING (SELECT scope, description, icon, restricted, default_scope, structured, structured_param_description FROM system_scope_TEMP) vals USING (SELECT scope, description, icon, restricted, default_scope FROM system_scope_TEMP) vals
ON (vals.scope = system_scope.scope) ON (vals.scope = system_scope.scope)
WHEN NOT MATCHED THEN WHEN NOT MATCHED THEN
INSERT (id, scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES(system_scope_seq.nextval, vals.scope, INSERT (id, scope, description, icon, restricted, default_scope) VALUES(system_scope_seq.nextval, vals.scope,
vals.description, vals.icon, vals.restricted, vals.default_scope, vals.structured, vals.structured_param_description); vals.description, vals.icon, vals.restricted, vals.default_scope);

View File

@ -239,8 +239,6 @@ CREATE TABLE IF NOT EXISTS system_scope (
icon VARCHAR(256), icon VARCHAR(256),
restricted BOOLEAN DEFAULT false NOT NULL, restricted BOOLEAN DEFAULT false NOT NULL,
default_scope BOOLEAN DEFAULT false NOT NULL, default_scope BOOLEAN DEFAULT false NOT NULL,
structured BOOLEAN DEFAULT false NOT NULL,
structured_param_description VARCHAR(256),
UNIQUE (scope) UNIQUE (scope)
); );

View File

@ -10,20 +10,20 @@ START TRANSACTION;
-- Insert scope information into the temporary tables. -- Insert scope information into the temporary tables.
-- --
INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope) VALUES
('openid', 'log in using your identity', 'user', false, true, false, null), ('openid', 'log in using your identity', 'user', false, true),
('profile', 'basic profile information', 'list-alt', false, true, false, null), ('profile', 'basic profile information', 'list-alt', false, true),
('email', 'email address', 'envelope', false, true, false, null), ('email', 'email address', 'envelope', false, true),
('address', 'physical address', 'home', false, true, false, null), ('address', 'physical address', 'home', false, true),
('phone', 'telephone number', 'bell', false, true, false, null), ('phone', 'telephone number', 'bell', false, true),
('offline_access', 'offline access', 'time', false, false, false, null); ('offline_access', 'offline access', 'time', false, false);
-- --
-- Merge the temporary scopes safely into the database. This is a two-step process to keep scopes from being created on every startup with a persistent store. -- Merge the temporary scopes safely into the database. This is a two-step process to keep scopes from being created on every startup with a persistent store.
-- --
INSERT INTO system_scope (scope, description, icon, restricted, default_scope, structured, structured_param_description) INSERT INTO system_scope (scope, description, icon, restricted, default_scope)
SELECT scope, description, icon, restricted, default_scope, structured, structured_param_description FROM system_scope_TEMP SELECT scope, description, icon, restricted, default_scope FROM system_scope_TEMP
ON CONFLICT(scope) ON CONFLICT(scope)
DO NOTHING; DO NOTHING;