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

delete from categorykeywords where internal = 1;
delete from documentkeywords where internal = 1;

/*==============================================================*/
/* View: CATEGORIES_WRITABLE_BY_USER                            */
/*==============================================================*/

CREATE VIEW CATEGORIES_WRITABLE_BY_USER (
  CATEGORYID,
  USERID
) AS SELECT CATEGORIES.CATEGORYID,
            CATEGORYACLS.ACCESSORID
       FROM CATEGORIES, CATEGORYACLS
      WHERE CATEGORIES.ACLID = CATEGORYACLS.ACLID 
        AND ( CATEGORYACLS.ACLTYPEID=1 OR CATEGORYACLS.ACLTYPEID=3 ) 
        AND CATEGORYACLS.PERMISSIONID = 3;

/*==============================================================*/
/* View: CATEGORIES_WRITABLE_BY_GROUP                           */
/*==============================================================*/
CREATE VIEW CATEGORIES_WRITABLE_BY_GROUP (
  CATEGORYID,
  GROUPID
) AS SELECT CATEGORIES.CATEGORYID,
            CATEGORYACLS.ACCESSORID
       FROM CATEGORIES, CATEGORYACLS
      WHERE CATEGORIES.ACLID = CATEGORYACLS.ACLID 
        AND CATEGORYACLS.ACLTYPEID=2 
        AND CATEGORYACLS.PERMISSIONID = 3;

/*==============================================================*/
/* View: CATEGORIES_WRITABLE_BY_LGROUP                          */
/*                                                              */ 
/* LGROUP = LDAP-GROUPS                                         */ 
/*                                                              */       
/* "AND CATEGORYACLS.ACCESSORID = LDAPGROUPS.LDAPGROUPID" is    */
/*  to prevent ldapgroups (of acls) being listed which are not  */
/*  existent any longer due to fragments left by                */
/*  VKCAclSerializer.deleteObsoleteGroups                       */
/*==============================================================*/
  
CREATE VIEW CATEGORIES_WRITABLE_BY_LGROUP (
  CATEGORYID, 
  LDAPGROUPID
) AS SELECT CATEGORIES.CATEGORYID,
            CATEGORYACLS.ACCESSORID
       FROM CATEGORIES, CATEGORYACLS, LDAPGROUPS
      WHERE CATEGORIES.ACLID = CATEGORYACLS.ACLID
        AND CATEGORYACLS.ACLTYPEID=7
        AND CATEGORYACLS.PERMISSIONID = 3
        AND CATEGORYACLS.ACCESSORID = LDAPGROUPS.LDAPGROUPID;  

