{$IFNOTEXISTS SELECT 1 FROM RDB$RELATION_FIELDS	WHERE RDB$FIELD_NAME = 'ORDER_DATE' AND RDB$RELATION_NAME = 'DOCUMENTS'}

  ALTER TABLE DOCUMENTS ADD ORDER_DATE DATE;
  ALTER TABLE DOCUMENTS ADD ACTION_DATE DATE;
  ALTER TABLE DOCUMENTS ADD ORDER_NUM VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8;
  COMMIT WORK;

{$ENDIF}

{$IFNOTEXISTS SELECT 1 FROM RDB$RELATION_FIELDS	WHERE RDB$FIELD_NAME = 'DPL_DATA' AND RDB$RELATION_NAME = 'DOCUMENTS'}

  ALTER TABLE DOCUMENTS ADD DPL_DATA VARCHAR(4000) CHARACTER SET UTF8 COLLATE UTF8;
  COMMIT WORK;

{$ENDIF}

{$IFNOTEXISTS SELECT 1 FROM RDB$RELATION_FIELDS	WHERE RDB$FIELD_NAME = 'N_PAGES' AND RDB$RELATION_NAME = 'DOCUMENTS'}

  ALTER TABLE DOCUMENTS ADD N_PAGES SMALLINT;
  COMMIT WORK;

{$ENDIF}

{$IFNOTEXISTS SELECT 1 FROM RDB$RELATION_FIELDS	WHERE RDB$FIELD_NAME = 'FRONT_ID' AND RDB$RELATION_NAME = 'BLANKS'}

  ALTER TABLE BLANKS ADD FRONT_ID BIGINT;
  COMMIT WORK;
  CREATE INDEX BLANKS_IDX1 ON BLANKS (FRONT_ID);
  COMMIT WORK;

{$ENDIF}


{$IFNOTEXISTS SELECT 1 FROM RDB$RELATION_FIELDS	WHERE RDB$FIELD_NAME = 'DUB_STATE' AND RDB$RELATION_NAME = 'DOCUMENTS'}

  ALTER TABLE DOCUMENTS ADD DUB_STATE SMALLINT DEFAULT 0;
  COMMIT WORK;

{$ENDIF}

{$IFNOTEXISTS SELECT 1 FROM RDB$RELATION_FIELDS	WHERE RDB$FIELD_NAME = 'SPO_REGNUM' AND RDB$RELATION_NAME = 'DOCUMENTS'}

  ALTER TABLE DOCUMENTS ADD SPO_REGNUM VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8;
  COMMIT WORK;

{$ENDIF}

{$IFNOTEXISTS SELECT 1 FROM RDB$RELATION_FIELDS	WHERE RDB$FIELD_NAME = 'SUBTYPE_ID' AND RDB$RELATION_NAME = 'BLANK_PACKS'}

  ALTER TABLE BLANK_PACKS ADD SUBTYPE_ID SMALLINT DEFAULT 0 NOT NULL;
  ALTER TABLE BLANK_PACKS ADD COMMENTS VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8;
  COMMIT WORK;

{$ENDIF}
