/*ALIAS>prop_db*/

/*SQLStart>2723*/
CREATE TABLE HISTORY_DOCUMENTS
(HD_ID INTEGER NOT null,
HD_MASTERID INTEGER NOT null,
 HD_DATE DATE,
 HD_USERID INTEGER,
 HD_ACTIONTYPE INTEGER,
 HD_DOCUMENTTYPE INTEGER,
 HD_BLOB  BLOB SUB_TYPE 1 SEGMENT SIZE 80
);
/*SQLStop*/

/*SQLStart>2724*/
grant ALL ON history_documents TO PUBLIC;
/*SQLStop*/

/*SQLStart>2725*/
CREATE GENERATOR HD_ID_GEN;
/*SQLStop*

/*SQLStart>2726*/
SET GENERATOR HD_ID_GEN TO 0;
/*SQLStop*

 /*SQLStart>2727*/
  alter table documents
  add DOC_DESC BLOB SUB_TYPE 1 SEGMENT SIZE 80;
  /*SQLStop*

 /*SQLStart>2728*/
 alter table documents
 add DOC_BORDERS BLOB SUB_TYPE 1 SEGMENT SIZE 80;
 /*SQLStop*

  /*SQLStart>2729*/
 update documents set documents.doc_desc = (select first 1 imot.im_desc from imot
inner join propdocs on propdocs.propertyid = imot.im_id where propdocs.documentid = documents.doc_id)
where documents.doc_type in (12, 8012);
/*SQLStop*

/*SQLStart>2730*/
update documents set documents.doc_borders = (select first 1 imot.im_borders from imot
inner join propdocs on propdocs.propertyid = imot.im_id where propdocs.documentid = documents.doc_id)
where documents.doc_type in (12, 8012);
/*SQLStop*


/*SQLStart>2731*/
update system_strings set sys_str = '6.7.226.1' where sys_id = 1401;  /*BackOffice*/
/*SQLStop*/