CREATE TABLE IF NOT EXISTS `forecasting` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `projectId` INT NOT NULL,
    `versionNumber` INT NOT NULL,
    `createdAt` DATETIME NOT NULL,
    FOREIGN KEY (`projectId`) REFERENCES `projects`(`id`) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS `forecastAllocation` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `forecastingId` INT NOT NULL,
    `rosterId` INT NOT NULL,
    `resourceName` VARCHAR(255) NOT NULL,
    `level` VARCHAR(255) NOT NULL,
    `month` DATE NOT NULL,
    `allocatedDays` DECIMAL(5, 2) NOT NULL DEFAULT 0.00,
    FOREIGN KEY (`forecastingId`) REFERENCES `forecasting`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`rosterId`) REFERENCES `roster`(`id`) ON DELETE CASCADE
);
