DROP TABLE IF EXISTS `servicerecord2signaturehistory`;
DROP TABLE IF EXISTS `signaturehistory`;


CREATE TABLE IF NOT EXISTS `signaturehistory` (
	`Oid` BIGINT AUTO_INCREMENT PRIMARY KEY,
    `Tid` INT DEFAULT NULL,
    `Version` BIGINT DEFAULT NULL,
    `IsActive` TINYINT DEFAULT NULL,
    `InsTs` DATETIME DEFAULT NULL,
    `SystemEntryID` INT DEFAULT NULL,
    `InsUser` VARCHAR(256) DEFAULT NULL,
    `UdpUser` VARCHAR(256) DEFAULT NULL,
    `Notice` VARCHAR(1024) DEFAULT NULL,
    `SignatureOid` BIGINT DEFAULT NULL,
    `SignatureType` INT DEFAULT NULL,
    `SignatureInsTs` DATETIME DEFAULT NULL,
    `CustomerOid` BIGINT DEFAULT NULL,
    `EmployeeOid` BIGINT DEFAULT NULL,
    `BargeldtransaktionsOid` BIGINT DEFAULT NULL,
    `SignatureTimeSpanStart` DATETIME DEFAULT NULL,
    `SignatureTimeSpanEnd` DATETIME DEFAULT NULL,
    `SignatureEventType` INT DEFAULT NULL
) Engine=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `servicerecord2signaturehistory` (
	`Oid` BIGINT AUTO_INCREMENT PRIMARY KEY,
    `SignatureHistoryOid` BIGINT DEFAULT NULL,
    `ServiceRecordOid` BIGINT DEFAULT NULL,
    FOREIGN KEY (`SignatureHistoryOid`) REFERENCES `signaturehistory`(`Oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

