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
/

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
/

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
/

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
/

commit
/

