update SYSPARAMETERS set VALUESTRING = '1'  where CONTEXT = 'SYSTEMINFO' and name = 'DBVersionHigh';
update SYSPARAMETERS set VALUESTRING = '165' where CONTEXT = 'SYSTEMINFO' and name = 'DBVersionLow';
update SYSPARAMETERS set VALUESTRING = '2006-02-27' where CONTEXT = 'SYSTEMINFO' and name = 'DBCreationDate';

alter table users
   add manageOwnUsersSystemViews integer,
   add manageVirtualDocumentQueries integer,
   add allowManageSystemViewType integer,
   add systemViewTypeId integer;

update users
   set manageOwnUsersSystemViews = 0,
   	   manageVirtualDocumentQueries = 0,
       allowManageSystemViewType = 0,
       systemViewTypeId = 2;

drop index INDEX_9;
drop index INDEX_12;

alter table users alter column username type varchar(62);
alter table users alter column lastname type varchar(199);
alter table users alter column firstname type varchar(199);

alter table groups alter column name type varchar(62);
alter table groups alter column name_key type varchar(199);
alter table groups alter column description type varchar(199);
alter table groups alter column descr_key type varchar(199);

create unique asc index INDEX_12 on GROUPS (
NAME
);

create unique asc index INDEX_9 on USERS (
USERNAME,
EXTERNALSERVERID
);

commit;