CREATE TABLE `ApexClass` (
    `Id` int(11) NOT NULL,
    `NamespacePrefix` varchar(255),
    `Name` varchar(255),
    `ApiVersion` varchar(255),
    `Status` varchar(255),
    `IsValid` int(11),
    `BodyCrc` varchar(255),
    `Body` text,
    `LengthWithoutComments` 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),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ApexClass_CreatedById` FOREIGN KEY (`CreatedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexClass_LastModifiedById` FOREIGN KEY (`LastModifiedById`) REFERENCES `User` (`Id`)
);
CREATE TABLE `ApexComponent` (
    `Id` int(11) NOT NULL,
    `NamespacePrefix` varchar(255),
    `Name` varchar(255),
    `ApiVersion` varchar(255),
    `MasterLabel` varchar(255),
    `Description` text,
    `ControllerType` varchar(255),
    `ControllerKey` varchar(255),
    `Markup` text,
    `CreatedDate` varchar(255),
    `CreatedById` int(11), -- foreign key: User.Id,
    `LastModifiedDate` varchar(255),
    `LastModifiedById` int(11), -- foreign key: User.Id,
    `SystemModstamp` varchar(255),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ApexComponent_CreatedById` FOREIGN KEY (`CreatedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexComponent_LastModifiedById` FOREIGN KEY (`LastModifiedById`) REFERENCES `User` (`Id`)
);
CREATE TABLE `ApexEmailNotification` (
    `Id` int(11) NOT NULL,
    `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),
    `UserId` int(11), -- foreign key: User.Id,
    `Email` varchar(255),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ApexEmailNotification_CreatedById` FOREIGN KEY (`CreatedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexEmailNotification_LastModifiedById` FOREIGN KEY (`LastModifiedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexEmailNotification_UserId` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`)
);
CREATE TABLE `ApexLog` (
    `Id` int(11) NOT NULL,
    `LogUserId` int(11), -- foreign key: User.Id,
    `LogLength` int(11),
    `LastModifiedDate` varchar(255),
    `Request` varchar(255),
    `Operation` varchar(255),
    `Application` varchar(255),
    `Status` varchar(255),
    `DurationMilliseconds` int(11),
    `SystemModstamp` varchar(255),
    `StartTime` varchar(255),
    `Location` varchar(255),
    `RequestIdentifier` varchar(255),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ApexLog_LogUserId` FOREIGN KEY (`LogUserId`) REFERENCES `User` (`Id`)
);
CREATE TABLE `ApexPage` (
    `Id` int(11) NOT NULL,
    `NamespacePrefix` varchar(255),
    `Name` varchar(255),
    `ApiVersion` varchar(255),
    `MasterLabel` varchar(255),
    `Description` text,
    `ControllerType` varchar(255),
    `ControllerKey` varchar(255),
    `IsAvailableInTouch` int(11),
    `IsConfirmationTokenRequired` int(11),
    `Markup` text,
    `CreatedDate` varchar(255),
    `CreatedById` int(11), -- foreign key: User.Id,
    `LastModifiedDate` varchar(255),
    `LastModifiedById` int(11), -- foreign key: User.Id,
    `SystemModstamp` varchar(255),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ApexPage_CreatedById` FOREIGN KEY (`CreatedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexPage_LastModifiedById` FOREIGN KEY (`LastModifiedById`) REFERENCES `User` (`Id`)
);
CREATE TABLE `ApexPageInfo` (
    `Id` int(11) NOT NULL,
    `DurableId` varchar(255),
    `ApexPageId` varchar(255),
    `Name` varchar(255),
    `NameSpacePrefix` varchar(255),
    `ApiVersion` varchar(255),
    `Description` text,
    `IsAvailableInTouch` int(11),
    `MasterLabel` varchar(255),
    `IsShowHeader` varchar(255),
    PRIMARY KEY (`Id`) 
);
CREATE TABLE `ApexTestQueueItem` (
    `Id` int(11) NOT NULL,
    `CreatedDate` varchar(255),
    `CreatedById` int(11), -- foreign key: User.Id,
    `SystemModstamp` varchar(255),
    `ApexClassId` int(11), -- foreign key: ApexClass.Id,
    `Status` varchar(255),
    `ExtendedStatus` varchar(255),
    `ParentJobId` int(11), -- foreign key: AsyncApexJob.Id,
    `TestRunResultId` int(11), -- foreign key: ApexTestRunResult.Id,
    `ShouldSkipCodeCoverage` int(11),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ApexTestQueueItem_CreatedById` FOREIGN KEY (`CreatedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexTestQueueItem_ApexClassId` FOREIGN KEY (`ApexClassId`) REFERENCES `ApexClass` (`Id`),
    CONSTRAINT `FK_ApexTestQueueItem_ParentJobId` FOREIGN KEY (`ParentJobId`) REFERENCES `AsyncApexJob` (`Id`),
    CONSTRAINT `FK_ApexTestQueueItem_TestRunResultId` FOREIGN KEY (`TestRunResultId`) REFERENCES `ApexTestRunResult` (`Id`)
);
CREATE TABLE `ApexTestResult` (
    `Id` int(11) NOT NULL,
    `SystemModstamp` varchar(255),
    `TestTimestamp` varchar(255),
    `Outcome` varchar(255),
    `ApexClassId` int(11), -- foreign key: ApexClass.Id,
    `MethodName` varchar(255),
    `Message` varchar(255),
    `StackTrace` varchar(255),
    `AsyncApexJobId` int(11), -- foreign key: AsyncApexJob.Id,
    `QueueItemId` int(11), -- foreign key: ApexTestQueueItem.Id,
    `ApexLogId` int(11), -- foreign key: ApexLog.Id,
    `ApexTestRunResultId` int(11), -- foreign key: ApexTestRunResult.Id,
    `RunTime` int(11),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ApexTestResult_ApexClassId` FOREIGN KEY (`ApexClassId`) REFERENCES `ApexClass` (`Id`),
    CONSTRAINT `FK_ApexTestResult_AsyncApexJobId` FOREIGN KEY (`AsyncApexJobId`) REFERENCES `AsyncApexJob` (`Id`),
    CONSTRAINT `FK_ApexTestResult_QueueItemId` FOREIGN KEY (`QueueItemId`) REFERENCES `ApexTestQueueItem` (`Id`),
    CONSTRAINT `FK_ApexTestResult_ApexLogId` FOREIGN KEY (`ApexLogId`) REFERENCES `ApexLog` (`Id`),
    CONSTRAINT `FK_ApexTestResult_ApexTestRunResultId` FOREIGN KEY (`ApexTestRunResultId`) REFERENCES `ApexTestRunResult` (`Id`)
);
CREATE TABLE `ApexTestResultLimits` (
    `Id` int(11) NOT NULL,
    `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),
    `ApexTestResultId` int(11), -- foreign key: ApexTestResult.Id,
    `Soql` int(11),
    `QueryRows` int(11),
    `Sosl` int(11),
    `Dml` int(11),
    `DmlRows` int(11),
    `Cpu` int(11),
    `Callouts` int(11),
    `Email` int(11),
    `AsyncCalls` int(11),
    `MobilePush` int(11),
    `LimitContext` varchar(255),
    `LimitExceptions` varchar(255),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ApexTestResultLimits_CreatedById` FOREIGN KEY (`CreatedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexTestResultLimits_LastModifiedById` FOREIGN KEY (`LastModifiedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexTestResultLimits_ApexTestResultId` FOREIGN KEY (`ApexTestResultId`) REFERENCES `ApexTestResult` (`Id`)
);
CREATE TABLE `ApexTestRunResult` (
    `Id` int(11) NOT NULL,
    `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),
    `AsyncApexJobId` int(11), -- foreign key: AsyncApexJob.Id,
    `UserId` int(11), -- foreign key: User.Id,
    `JobName` varchar(255),
    `IsAllTests` int(11),
    `Source` varchar(255),
    `StartTime` varchar(255),
    `EndTime` varchar(255),
    `TestTime` int(11),
    `Status` varchar(255),
    `ClassesEnqueued` int(11),
    `ClassesCompleted` int(11),
    `MethodsEnqueued` int(11),
    `MethodsCompleted` int(11),
    `MethodsFailed` int(11),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ApexTestRunResult_CreatedById` FOREIGN KEY (`CreatedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexTestRunResult_LastModifiedById` FOREIGN KEY (`LastModifiedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexTestRunResult_AsyncApexJobId` FOREIGN KEY (`AsyncApexJobId`) REFERENCES `AsyncApexJob` (`Id`),
    CONSTRAINT `FK_ApexTestRunResult_UserId` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`)
);
CREATE TABLE `ApexTestSuite` (
    `Id` int(11) NOT NULL,
    `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),
    `TestSuiteName` varchar(255),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ApexTestSuite_CreatedById` FOREIGN KEY (`CreatedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexTestSuite_LastModifiedById` FOREIGN KEY (`LastModifiedById`) REFERENCES `User` (`Id`)
);
CREATE TABLE `ApexTrigger` (
    `Id` int(11) NOT NULL,
    `NamespacePrefix` varchar(255),
    `Name` varchar(255),
    `TableEnumOrId` varchar(255),
    `UsageBeforeInsert` int(11),
    `UsageAfterInsert` int(11),
    `UsageBeforeUpdate` int(11),
    `UsageAfterUpdate` int(11),
    `UsageBeforeDelete` int(11),
    `UsageAfterDelete` int(11),
    `UsageIsBulk` int(11),
    `UsageAfterUndelete` int(11),
    `ApiVersion` varchar(255),
    `Status` varchar(255),
    `IsValid` int(11),
    `BodyCrc` varchar(255),
    `Body` text,
    `LengthWithoutComments` 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),
    PRIMARY KEY (`Id`) ,
    CONSTRAINT `FK_ApexTrigger_CreatedById` FOREIGN KEY (`CreatedById`) REFERENCES `User` (`Id`),
    CONSTRAINT `FK_ApexTrigger_LastModifiedById` FOREIGN KEY (`LastModifiedById`) REFERENCES `User` (`Id`)
);
