BEGIN;

create temp sequence temp_turbine_user_seq start with 1;
select setval('temp_turbine_user_seq', (select max(user_id) from turbine_user));
create temp sequence temp_turbine_role_seq start with 1;
select setval('temp_turbine_role_seq', (select max(role_id) from turbine_role));


INSERT INTO turbine_user VALUES (nextval('temp_turbine_user_seq'), 'AnnounceAdmin', 'W6ph5Mm5Pz8GgiULbPgzG37mj9g=', 'Test', 'AnnounceAdmin', 'adaptone.qa@gmail.com', NULL, NULL, NULL, current_timestamp, '', NULL, 'Available');
INSERT INTO turbine_user VALUES (nextval('temp_turbine_user_seq'), 'AnnounceUser', 'W6ph5Mm5Pz8GgiULbPgzG37mj9g=', 'Test', 'AnnounceUser', 'adaptone.qa@gmail.com', NULL, NULL, NULL, current_timestamp, '', NULL, 'Available');

INSERT INTO turbine_role values (nextval('temp_turbine_role_seq'), 'AnnounceAdminRole');
INSERT INTO turbine_role values (nextval('temp_turbine_role_seq'), 'AnnounceUserRole');
INSERT INTO turbine_user_group_role (user_id, group_id, role_id)
	values ((select user_id from turbine_user where login_name = 'AnnounceAdmin'),
		    (select group_id from turbine_group where group_name = 'global'),
 		    (select role_id from turbine_role where role_name = 'AnnounceAdminRole'));
INSERT INTO turbine_user_group_role (user_id, group_id, role_id)
	values ((select user_id from turbine_user where login_name = 'AnnounceUser'),
		    (select group_id from turbine_group where group_name = 'global'),
 		    (select role_id from turbine_role where role_name = 'AnnounceUserRole'));
    
create table configmgmt_temp as select * from configmgmt  where name = 'contentMgmt.admin.roles';    
    
UPDATE configmgmt set value = 'CouncilAdministrator,ContentAdministrator,AnnounceAdminRole' where name ='contentMgmt.admin.roles';

UPDATE id_table set next_id = nextval('temp_turbine_user_seq') + 10 where table_name = 'TURBINE_USER';
UPDATE id_table set next_id = nextval('temp_turbine_role_seq') + 10 where table_name = 'TURBINE_ROLE';

COMMIT;