
ALTER TABLE `AssessmentSheetValue` ADD COLUMN `Position` INT(11) NULL DEFAULT NULL;

ALTER TABLE `AssessmentSheetCategory` ADD COLUMN `Position` INT(11) NULL DEFAULT NULL;

ALTER TABLE `Mandator` ADD COLUMN `Settings` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL;

ALTER TABLE `ServiceRecord` ADD COLUMN `GroupPersonCount` INTEGER(10) DEFAULT NULL;

ALTER TABLE `ServiceRecord` ADD COLUMN `GroupRoundedDuration` DECIMAL(18,10) DEFAULT NULL;

ALTER TABLE `ServiceRecord` ADD COLUMN `GroupId` BIGINT(19) NULL DEFAULT NULL;

ALTER TABLE `ServiceRecord` ADD INDEX `IDX_GroupId` (`GroupId` ASC) ;

ALTER TABLE `InvoiceBase` ADD COLUMN `XMLData` VARCHAR(4000) NULL DEFAULT NULL ;

ALTER TABLE `query` ADD COLUMN `UserGroupOids` VARCHAR(1024) NULL DEFAULT NULL ;





//für christian
ALTER TABLE `servicerecord` ADD COLUMN `GroupEmployeeCount` INTEGER(10) DEFAULT NULL;


//für online dbs


ALTER TABLE `servicerecord` MODIFY COLUMN `RoundedDuration` DECIMAL(18,10) DEFAULT NULL;

ALTER TABLE `servicerecord` MODIFY COLUMN `GroupRoundedDuration` DECIMAL(18,10) DEFAULT NULL;

alter TABLE `servicerecord` DROP INDEX `IDX_GroupId`;

alter TABLE `servicerecord` DROP COLUMN `groupid`;


CREATE TABLE `servicerecordgroup` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) DEFAULT NULL,
  `CustomerCount` INTEGER(10) DEFAULT NULL,
  `EmployeeCount` INTEGER(10) DEFAULT NULL,
  `RoundedDuration` DECIMAL(18,10) DEFAULT NULL,
  `StartDate` DATETIME DEFAULT NULL,
  `EndDate` DATETIME DEFAULT NULL,
  `Notice` MEDIUMTEXT DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

ALTER TABLE `servicerecord` ADD `GroupOid` BIGINT(19) DEFAULT NULL;
ALTER TABLE `servicerecord` ADD  KEY `FK_GROUP` (`GroupOid`);
ALTER TABLE `servicerecord` ADD  CONSTRAINT `FK_GROUP` FOREIGN KEY (`GroupOid`) REFERENCES `servicerecordgroup` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION;



//18.5.

ALTER TABLE `diagnosis2customer`  DROP FOREIGN KEY `FK_DIAGNOSIS2_CUSTOMER_DIAGNOSIS`;
ALTER TABLE `diagnosis2customer`  DROP INDEX `DIAGNOSISDIAGNOSIS2CUSTOMER_FK` ;
ALTER TABLE `diagnosis2customer` CHANGE COLUMN `DiagnosisOid` `ICD10DiagnosisCode` VARCHAR(128) NOT NULL;

DROP TABLE `diagnosis` ;

CREATE  TABLE IF NOT EXISTS `VarFieldDef` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` VARCHAR(45) NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `GroupString` VARCHAR(512) NULL ,
  `XCoordinate` INT(10) NULL ,
  `YCoordinate` INT(10) NULL ,
  `Label` VARCHAR(512) NULL ,
  `ControlType` INT(10) NULL ,
  `PossibleItems` VARCHAR(2048) NULL ,
  `DecimalPlaces` INT(10) NULL ,
  `ObjectTid` INT(10) NULL ,
  PRIMARY KEY (`Oid`) )
ENGINE = InnoDB;


CREATE  TABLE `VarFieldValue` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` VARCHAR(45) NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `SerializedValue` VARCHAR(512) NULL ,
  `TypeName` VARCHAR(512) NULL ,
  `VarFieldDefOid` BIGINT(19) NULL ,
  `ObjectOid` BIGINT(19) NULL ,
  `ObjectTid` INT(10) NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `VarFieldValue_VarFieldDef_fk` (`VarFieldDefOid` ASC) ,
  CONSTRAINT `VarFieldValue_VarFieldDef_fk`
    FOREIGN KEY (`VarFieldDefOid` )
    REFERENCES `VarFieldDef` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE  TABLE `Customer2AssessmentSheetCategory` (
  `CustomerOid` BIGINT(19) NOT NULL ,
  `AssessmentSheetOid` BIGINT(19) NOT NULL ,
  INDEX `Cus` (`CustomerOid` ASC) ,
  INDEX `Ass` (`AssessmentSheetOid` ASC) ,
  PRIMARY KEY (`CustomerOid`, `AssessmentSheetOid`) ,
  CONSTRAINT `Cus`
    FOREIGN KEY (`CustomerOid` )
    REFERENCES `customer` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `Ass`
    FOREIGN KEY (`AssessmentSheetOid` )
    REFERENCES `AssessmentSheetCategory` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_swedish_ci;

ALTER TABLE `Customer` ADD COLUMN `Medication` VARCHAR(1024) NULL DEFAULT NULL;

ALTER TABLE `invoiceitem` MODIFY COLUMN `UnitCount` DECIMAL(12,4) DEFAULT NULL;

// 29.6.

ALTER TABLE `costbearer` ADD COLUMN `IsCalculatingWithFactor` TINYINT(4) DEFAULT NULL;

ALTER TABLE `address` ADD COLUMN `AddressLine1` VARCHAR(64) DEFAULT NULL;

ALTER TABLE `address` ADD COLUMN `AddressLine2` VARCHAR(64) DEFAULT NULL;



//###

ALTER TABLE `appuserfileattachmentlock` ADD KEY `ObjectOid_IDX` (`ObjectOid`);

ALTER TABLE `fileattachment` ADD KEY `ObjectOid_IDX` (`ObjectOid`);

ALTER TABLE `settings` ADD KEY `ObjectOid_IDX` (`ObjectOid`);

ALTER TABLE `valuelistentry2object` ADD KEY `ObjectOid_IDX` (`ObjectOid`);

ALTER TABLE `followup` ADD KEY `ObjectOid_IDX` (`ObjectOid`);

ALTER TABLE `costrateperiod` ADD KEY `ObjectOid_IDX` (`ObjectOid`);

ALTER TABLE `VarFieldDef` ADD KEY `ObjectTid_IDX` (`ObjectTid`);

ALTER TABLE `VarFieldValue` ADD KEY `ObjectOid_IDX` (`ObjectOid`);

ALTER TABLE `VarFieldValue` ADD KEY `ObjectTid_IDX` (`ObjectTid`);



CREATE  TABLE  `Task` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` VARCHAR(45) NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `SupportConceptOid` BIGINT(19) NULL ,
  `Description` MEDIUMTEXT NULL ,
  `Title` MEDIUMTEXT NULL ,
  `CompletedDate` DATETIME NULL ,
  `CompletedNotice` MEDIUMTEXT NULL ,
  `DueDate` DATETIME NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `fk_task_supportConcet` (`SupportConceptOid` ASC) ,
  CONSTRAINT `fk_task_supportConcet`
    FOREIGN KEY (`SupportConceptOid` )
    REFERENCES `supportconcept` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE  TABLE `Task2Employee` (
  `TaskOid` BIGINT(19) NOT NULL ,
  `EmployeeOid` BIGINT(19) NOT NULL ,
  PRIMARY KEY (`TaskOid`, `EmployeeOid`) ,
  INDEX `fk_t2em_e` (`EmployeeOid` ASC) ,
  INDEX `fk_t2em_t` (`TaskOid` ASC) ,
  CONSTRAINT `fk_t2em_e`
    FOREIGN KEY (`EmployeeOid` )
    REFERENCES `employee` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_t2em_t`
    FOREIGN KEY (`TaskOid` )
    REFERENCES `Task` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


//alle migriert


//ab 1.9.2010

CREATE  TABLE IF NOT EXISTS `newsitem` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` VARCHAR(45) NULL DEFAULT NULL ,
  `Notice` VARCHAR(1024) NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  `PublishDate` DATETIME NULL DEFAULT NULL ,
  `Title` VARCHAR(256) NULL DEFAULT NULL ,
  `Text` MEDIUMTEXT NULL DEFAULT NULL ,
  PRIMARY KEY (`Oid`) )
ENGINE = InnoDB;

CREATE  TABLE IF NOT EXISTS `BeWoFolder` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `ObjectOid` BIGINT(19) NULL DEFAULT NULL ,
  `ObjectTid` INT(10) NULL DEFAULT NULL ,
  `Name` VARCHAR(1024) NULL ,
  `Notice` VARCHAR(1024) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `IsActive` TINYINT(4) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  `ParentBeWoFolderOid` BIGINT(19) NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `folder_pFolder` (`ParentBeWoFolderOid` ASC) ,
  CONSTRAINT `folder_pFolder`
    FOREIGN KEY (`ParentBeWoFolderOid` )
    REFERENCES `BeWoFolder` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE  TABLE IF NOT EXISTS `BeWoFile` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `Type` INT(10) NULL DEFAULT NULL ,
  `Path` VARCHAR(512) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `Notice` VARCHAR(1024) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `IsActive` TINYINT(4) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  `Data` MEDIUMBLOB NULL DEFAULT NULL ,
  `BeWoFolderOid` BIGINT(19) NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `file_folder_fk` (`BeWoFolderOid` ASC) ,
  CONSTRAINT `file_folder_fk`
    FOREIGN KEY (`BeWoFolderOid` )
    REFERENCES `BeWoFolder` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


ALTER TABLE `supportconcept` ADD COLUMN `ConferenceVenue` VARCHAR(1024) NULL DEFAULT NULL;

//ab 1.10.10