/*
  Warnings:

  - You are about to drop the column `owner` on the `content` table. All the data in the column will be lost.
  - You are about to drop the column `publisher` on the `content` table. All the data in the column will be lost.
  - A unique constraint covering the columns `[handle]` on the table `userHandle` will be added. If there are existing duplicate values, this will fail.

*/
-- AlterTable
ALTER TABLE `content` DROP COLUMN `owner`,
    DROP COLUMN `publisher`;

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

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

-- CreateIndex
CREATE UNIQUE INDEX `userHandle_handle_key` ON `userHandle`(`handle`);

-- AddForeignKey
ALTER TABLE `ContentHandle` ADD CONSTRAINT `ContentHandle_contentId_fkey` FOREIGN KEY (`contentId`) REFERENCES `content`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `ContentHandle` ADD CONSTRAINT `ContentHandle_handle_fkey` FOREIGN KEY (`handle`) REFERENCES `userHandle`(`handle`) ON DELETE RESTRICT ON UPDATE CASCADE;
