/*
  Warnings:

  - You are about to drop the `ContentHandle` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `userHandle` table. If the table is not empty, all the data it contains will be lost.
  - Added the required column `handleId` to the `content` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE `ContentHandle` DROP FOREIGN KEY `ContentHandle_contentId_fkey`;

-- DropForeignKey
ALTER TABLE `ContentHandle` DROP FOREIGN KEY `ContentHandle_handle_fkey`;

-- AlterTable
ALTER TABLE `content` ADD COLUMN `handleId` VARCHAR(191) NOT NULL;

-- DropTable
DROP TABLE `ContentHandle`;

-- DropTable
DROP TABLE `userHandle`;

-- CreateTable
CREATE TABLE `user` (
    `id` VARCHAR(191) NOT NULL,
    `email` VARCHAR(191) NOT NULL,
    `icon` VARCHAR(191) NOT NULL DEFAULT '',
    `isApproved` BOOLEAN NOT NULL DEFAULT false,
    `createtime` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `handle` (
    `id` VARCHAR(191) NOT NULL,
    `handle` VARCHAR(191) NOT NULL,
    `userId` VARCHAR(191) NOT NULL,

    UNIQUE INDEX `handle_handle_key`(`handle`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `content` ADD CONSTRAINT `content_handleId_fkey` FOREIGN KEY (`handleId`) REFERENCES `handle`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `handle` ADD CONSTRAINT `handle_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
