/*
  Warnings:

  - You are about to drop the column `api_key` on the `User` table. All the data in the column will be lost.
  - You are about to drop the column `secret_key` on the `User` table. All the data in the column will be lost.

*/
-- AlterTable
ALTER TABLE `User` DROP COLUMN `api_key`,
    DROP COLUMN `secret_key`;

-- CreateTable
CREATE TABLE `UserKey` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `api_key` VARCHAR(191) NOT NULL,
    `secret_key` VARCHAR(191) NOT NULL,
    `status` ENUM('EXPIRED', 'ACTIVE') NOT NULL,
    `userId` INTEGER NOT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `UserKey_api_key_key`(`api_key`),
    UNIQUE INDEX `UserKey_secret_key_key`(`secret_key`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `UserKey` ADD CONSTRAINT `UserKey_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
