-- AlterTable
ALTER TABLE `DriveFile` ADD COLUMN `folderId` VARCHAR(191) NULL;

-- CreateTable
CREATE TABLE `DriveFolder` (
    `id` VARCHAR(191) NOT NULL,
    `workspaceId` VARCHAR(191) NOT NULL,
    `parentId` VARCHAR(191) NULL,
    `ownerId` VARCHAR(191) NOT NULL,
    `name` VARCHAR(191) NOT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    INDEX `DriveFolder_workspaceId_idx`(`workspaceId`),
    INDEX `DriveFolder_parentId_idx`(`parentId`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateIndex
CREATE INDEX `DriveFile_folderId_idx` ON `DriveFile`(`folderId`);

-- AddForeignKey
ALTER TABLE `DriveFile` ADD CONSTRAINT `DriveFile_folderId_fkey` FOREIGN KEY (`folderId`) REFERENCES `DriveFolder`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `DriveFolder` ADD CONSTRAINT `DriveFolder_workspaceId_fkey` FOREIGN KEY (`workspaceId`) REFERENCES `Workspace`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `DriveFolder` ADD CONSTRAINT `DriveFolder_ownerId_fkey` FOREIGN KEY (`ownerId`) REFERENCES `User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `DriveFolder` ADD CONSTRAINT `DriveFolder_parentId_fkey` FOREIGN KEY (`parentId`) REFERENCES `DriveFolder`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
