CREATE TABLE `ActivityHistory` (
    `Id` int(11) NOT NULL,
    `AccountId` int(11), -- foreign key: Account.Id,
    `WhoId` int(11), -- foreign key: Lead.Id,
    `WhatId` int(11), -- foreign key: WorkOrderLineItem.Id,
    `Subject` varchar(255),
    `IsTask` int(11),
    `ActivityDate` varchar(255),
    `ActivityDateTime` varchar(255),
    `OwnerId` int(11), -- foreign key: User.Id,
    `Status` varchar(255),
    `Priority` varchar(255),
    `IsHighPriority` int(11),
    `ActivityType` varchar(255),
    `IsClosed` int(11),
    `IsAllDayEvent` int(11),
    `IsVisibleInSelfService` int(11),
    `DurationInMinutes` int(11),
    `Location` varchar(255),
    `Description` text,
    `CurrencyIsoCode` varchar(255),
    `IsDeleted` int(11),
    `CreatedDate` varchar(255),
    `CreatedById` int(11), -- foreign key: User.Id,
    `LastModifiedDate` varchar(255),
    `LastModifiedById` int(11), -- foreign key: User.Id,
    `SystemModstamp` varchar(255),
    `CallDurationInSeconds` int(11),
    `CallType` varchar(255),
    `CallDisposition` varchar(255),
    `CallObject` varchar(255),
    `ReminderDateTime` varchar(255),
    `IsReminderSet` int(11),
    `EndDateTime` varchar(255),
    `StartDateTime` varchar(255),
    `ActivitySubtype` varchar(255),
    `AlternateDetailId` int(11), -- foreign key: EmailMessage.Id,
    `CompletedDateTime` varchar(255),
    `Owner_Name__c` varchar(255),
    `S360_Frequency_Days__c` varchar(255),
    `S360_Internal_Tasks__c` varchar(255),
    `S360_Last_Reminder_Date__c` varchar(255),
    `S360_Purchaseforce_Link__c` varchar(255),
    `S360_Supplier_Tasks__c` varchar(255),
    `S360_Direct_Link__c` varchar(255),
    `CF_Blockers__c` text,
    `CF_Notes__c` text,
    `CF_Upcoming_Activity__c` varchar(255),
    `Close_Date__c` varchar(255),
    `Is_Treasury_User__c` int(11),
    `My_Tasks__c` int(11),
    `Task_Assigned_to_Me__c` int(11),
    `Task_Created_By_Me__c` int(11),
    `Agreement__c` int(11), -- foreign key: Apttus__APTS_Agreement__c.Id,
    `Created_by_Current_User__c` int(11),
    `Key_Agreement_Access_Information__c` varchar(255),
    `CLM_Created_From_Automation__c` int(11),
    `What_Name__c` varchar(255),
    `LC_Amount__c` varchar(255),
    `LC_Asset_Secured_Lease__c` varchar(255),
    `LC_Bank__c` varchar(255),
    `LC_Entity__c` varchar(255),
    `LC_No__c` varchar(255),
    `LC_Purpose__c` varchar(255),
    `LC_Record_No__c` varchar(255),
    `LC_Type__c` varchar(255),
    `Letter_of_Credit__c` int(11), -- foreign key: Letter_of_Credit__c.Id,
    `CLM_Agreement_Custom_Identifier__c` varchar(255),
    `Region__c` varchar(255),
    `CLM_QA_Score__c` varchar(255),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ActivityHistory_AccountId` FOREIGN KEY (`AccountId`) REFERENCES `Account` (`Id`),
    CONSTRAINT `FK_ActivityHistory_WhoId` FOREIGN KEY (`WhoId`) REFERENCES `Lead` (`Id`),
    CONSTRAINT `FK_ActivityHistory_WhatId` FOREIGN KEY (`WhatId`) REFERENCES `WorkOrderLineItem` (`Id`),
    CONSTRAINT `FK_ActivityHistory_OwnerId` FOREIGN KEY (`OwnerId`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ActivityHistory_CreatedById` FOREIGN KEY (`CreatedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ActivityHistory_LastModifiedById` FOREIGN KEY (`LastModifiedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ActivityHistory_AlternateDetailId` FOREIGN KEY (`AlternateDetailId`) REFERENCES `EmailMessage` (`Id`),
    CONSTRAINT `FK_ActivityHistory_Agreement_c` FOREIGN KEY (`Agreement__c`) REFERENCES `Apttus__APTS_Agreement__c` (`Id`),
    CONSTRAINT `FK_ActivityHistory_Letter_of_Credit_c` FOREIGN KEY (`Letter_of_Credit__c`) REFERENCES `Letter_of_Credit__c` (`Id`)
);
