-- CreateTable
CREATE TABLE `apiKey` (
    `id` VARCHAR(191) NOT NULL,
    `name` VARCHAR(191) NULL,
    `start` VARCHAR(191) NULL,
    `prefix` VARCHAR(191) NULL,
    `key` VARCHAR(191) NOT NULL,
    `userId` VARCHAR(255) NOT NULL,
    `refillInterval` INTEGER NULL,
    `refillAmmount` INTEGER NULL,
    `lastRefillAt` DATETIME(3) NULL,
    `enabled` BOOLEAN NOT NULL,
    `rateLimitEnabled` BOOLEAN NOT NULL,
    `rateLimitTimeWindow` INTEGER NULL,
    `rateLimitMax` INTEGER NULL,
    `requestCount` INTEGER NOT NULL,
    `remaining` INTEGER NULL,
    `lastRequest` DATETIME(3) NULL,
    `expiresAt` DATETIME(3) NULL,
    `createdAt` DATETIME(3) NOT NULL,
    `updatedAt` DATETIME(3) NOT NULL,
    `permissions` VARCHAR(191) NULL,
    `metadata` JSON NULL,

    PRIMARY KEY (`id`)
);

-- AddForeignKey
ALTER TABLE `apiKey` ADD CONSTRAINT `apiKey_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
