/*
  Warnings:

  - The `emails` column on the `account_email_request_entity` table would be dropped and recreated. This will lead to data loss if there is data in the column.
  - You are about to drop the column `pixelId` on the `pixel_transfer_request_entity` table. All the data in the column will be lost.
  - Added the required column `pixelExternalId` to the `pixel_transfer_request_entity` table without a default value. This is not possible if the table is not empty.

*/
-- CreateEnum
CREATE TYPE "AccountTroubleRequestIssueType" AS ENUM ('PAYMENT_ISSUE', 'SPEND_ISSUE', 'OTHER');

-- CreateEnum
CREATE TYPE "OsType" AS ENUM ('MAC', 'WINDOWS');

-- AlterEnum
ALTER TYPE "RequestType" ADD VALUE 'TOP_UP';

-- AlterTable
ALTER TABLE "account_email_request_entity" DROP COLUMN "emails",
ADD COLUMN     "emails" TEXT[];

-- AlterTable
ALTER TABLE "pixel_transfer_request_entity" DROP COLUMN "pixelId",
ADD COLUMN     "pixelExternalId" TEXT NOT NULL;

-- CreateTable
CREATE TABLE "money_transfer_request" (
    "id" SERIAL NOT NULL,
    "requestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "money_transfer_request_entity" (
    "id" SERIAL NOT NULL,
    "sum" DOUBLE PRECISION NOT NULL,
    "accountFromId" INTEGER NOT NULL,
    "accountToId" INTEGER NOT NULL,
    "moneyTransferRequestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "unblock_account_request" (
    "id" SERIAL NOT NULL,
    "requestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "unblock_account_request_entity" (
    "id" SERIAL NOT NULL,
    "accountId" INTEGER NOT NULL,
    "unblockAccountRequestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "cancel_account_request" (
    "id" SERIAL NOT NULL,
    "requestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "cancel_account_request_entity" (
    "id" SERIAL NOT NULL,
    "accountId" INTEGER NOT NULL,
    "cancelAccountRequestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "bm_invite_approve_request" (
    "id" SERIAL NOT NULL,
    "requestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "bm_invite_approve_request_entity" (
    "id" SERIAL NOT NULL,
    "bmExternalId" TEXT NOT NULL,
    "emails" TEXT[],
    "bmInviteApproveRequestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "account_trouble_approve_request" (
    "id" SERIAL NOT NULL,
    "requestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "account_trouble_approve_request_entity" (
    "id" SERIAL NOT NULL,
    "description" TEXT NOT NULL,
    "issueType" "AccountTroubleRequestIssueType" NOT NULL,
    "accountId" INTEGER NOT NULL,
    "accountTroubleRequestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "create_king_soc_request" (
    "id" SERIAL NOT NULL,
    "requestId" INTEGER NOT NULL,
    "os" "OsType" NOT NULL,
    "requestReason" TEXT NOT NULL,
    "quantity" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "create_king_soc_request_bm" (
    "id" SERIAL NOT NULL,
    "bmExternalId" TEXT NOT NULL,
    "createKingSocRequestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "create_king_soc_request_account" (
    "id" SERIAL NOT NULL,
    "accountId" INTEGER NOT NULL,
    "createKingSocRequestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "create_fan_page_soc_request" (
    "id" SERIAL NOT NULL,
    "requestReason" TEXT NOT NULL,
    "requestId" INTEGER NOT NULL
);

-- CreateTable
CREATE TABLE "create_fan_page_soc_request_entity" (
    "id" SERIAL NOT NULL,
    "bmExternalId" TEXT NOT NULL,
    "socAccountUrl" TEXT NOT NULL,
    "fanPageNames" TEXT[],
    "createFanPageRequestId" INTEGER NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "money_transfer_request_id_key" ON "money_transfer_request"("id");

-- CreateIndex
CREATE UNIQUE INDEX "money_transfer_request_requestId_key" ON "money_transfer_request"("requestId");

-- CreateIndex
CREATE UNIQUE INDEX "money_transfer_request_entity_id_key" ON "money_transfer_request_entity"("id");

-- CreateIndex
CREATE UNIQUE INDEX "unblock_account_request_id_key" ON "unblock_account_request"("id");

-- CreateIndex
CREATE UNIQUE INDEX "unblock_account_request_requestId_key" ON "unblock_account_request"("requestId");

-- CreateIndex
CREATE UNIQUE INDEX "unblock_account_request_entity_id_key" ON "unblock_account_request_entity"("id");

-- CreateIndex
CREATE UNIQUE INDEX "cancel_account_request_id_key" ON "cancel_account_request"("id");

-- CreateIndex
CREATE UNIQUE INDEX "cancel_account_request_requestId_key" ON "cancel_account_request"("requestId");

-- CreateIndex
CREATE UNIQUE INDEX "cancel_account_request_entity_id_key" ON "cancel_account_request_entity"("id");

-- CreateIndex
CREATE UNIQUE INDEX "bm_invite_approve_request_id_key" ON "bm_invite_approve_request"("id");

-- CreateIndex
CREATE UNIQUE INDEX "bm_invite_approve_request_requestId_key" ON "bm_invite_approve_request"("requestId");

-- CreateIndex
CREATE UNIQUE INDEX "bm_invite_approve_request_entity_id_key" ON "bm_invite_approve_request_entity"("id");

-- CreateIndex
CREATE UNIQUE INDEX "account_trouble_approve_request_id_key" ON "account_trouble_approve_request"("id");

-- CreateIndex
CREATE UNIQUE INDEX "account_trouble_approve_request_requestId_key" ON "account_trouble_approve_request"("requestId");

-- CreateIndex
CREATE UNIQUE INDEX "account_trouble_approve_request_entity_id_key" ON "account_trouble_approve_request_entity"("id");

-- CreateIndex
CREATE UNIQUE INDEX "create_king_soc_request_id_key" ON "create_king_soc_request"("id");

-- CreateIndex
CREATE UNIQUE INDEX "create_king_soc_request_requestId_key" ON "create_king_soc_request"("requestId");

-- CreateIndex
CREATE UNIQUE INDEX "create_king_soc_request_bm_id_key" ON "create_king_soc_request_bm"("id");

-- CreateIndex
CREATE UNIQUE INDEX "create_king_soc_request_account_id_key" ON "create_king_soc_request_account"("id");

-- CreateIndex
CREATE UNIQUE INDEX "create_fan_page_soc_request_id_key" ON "create_fan_page_soc_request"("id");

-- CreateIndex
CREATE UNIQUE INDEX "create_fan_page_soc_request_requestId_key" ON "create_fan_page_soc_request"("requestId");

-- CreateIndex
CREATE UNIQUE INDEX "create_fan_page_soc_request_entity_id_key" ON "create_fan_page_soc_request_entity"("id");

-- AddForeignKey
ALTER TABLE "money_transfer_request" ADD CONSTRAINT "money_transfer_request_requestId_fkey" FOREIGN KEY ("requestId") REFERENCES "request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "money_transfer_request_entity" ADD CONSTRAINT "money_transfer_request_entity_accountFromId_fkey" FOREIGN KEY ("accountFromId") REFERENCES "account"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "money_transfer_request_entity" ADD CONSTRAINT "money_transfer_request_entity_accountToId_fkey" FOREIGN KEY ("accountToId") REFERENCES "account"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "money_transfer_request_entity" ADD CONSTRAINT "money_transfer_request_entity_moneyTransferRequestId_fkey" FOREIGN KEY ("moneyTransferRequestId") REFERENCES "money_transfer_request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "unblock_account_request" ADD CONSTRAINT "unblock_account_request_requestId_fkey" FOREIGN KEY ("requestId") REFERENCES "request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "unblock_account_request_entity" ADD CONSTRAINT "unblock_account_request_entity_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "account"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "unblock_account_request_entity" ADD CONSTRAINT "unblock_account_request_entity_unblockAccountRequestId_fkey" FOREIGN KEY ("unblockAccountRequestId") REFERENCES "unblock_account_request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "cancel_account_request" ADD CONSTRAINT "cancel_account_request_requestId_fkey" FOREIGN KEY ("requestId") REFERENCES "request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "cancel_account_request_entity" ADD CONSTRAINT "cancel_account_request_entity_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "account"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "cancel_account_request_entity" ADD CONSTRAINT "cancel_account_request_entity_cancelAccountRequestId_fkey" FOREIGN KEY ("cancelAccountRequestId") REFERENCES "cancel_account_request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "bm_invite_approve_request" ADD CONSTRAINT "bm_invite_approve_request_requestId_fkey" FOREIGN KEY ("requestId") REFERENCES "request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "bm_invite_approve_request_entity" ADD CONSTRAINT "bm_invite_approve_request_entity_bmInviteApproveRequestId_fkey" FOREIGN KEY ("bmInviteApproveRequestId") REFERENCES "bm_invite_approve_request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "account_trouble_approve_request" ADD CONSTRAINT "account_trouble_approve_request_requestId_fkey" FOREIGN KEY ("requestId") REFERENCES "request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "account_trouble_approve_request_entity" ADD CONSTRAINT "account_trouble_approve_request_entity_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "account"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "account_trouble_approve_request_entity" ADD CONSTRAINT "account_trouble_approve_request_entity_accountTroubleReque_fkey" FOREIGN KEY ("accountTroubleRequestId") REFERENCES "account_trouble_approve_request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "create_king_soc_request" ADD CONSTRAINT "create_king_soc_request_requestId_fkey" FOREIGN KEY ("requestId") REFERENCES "request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "create_king_soc_request_bm" ADD CONSTRAINT "create_king_soc_request_bm_createKingSocRequestId_fkey" FOREIGN KEY ("createKingSocRequestId") REFERENCES "create_king_soc_request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "create_king_soc_request_account" ADD CONSTRAINT "create_king_soc_request_account_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "account"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "create_king_soc_request_account" ADD CONSTRAINT "create_king_soc_request_account_createKingSocRequestId_fkey" FOREIGN KEY ("createKingSocRequestId") REFERENCES "create_king_soc_request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "create_fan_page_soc_request" ADD CONSTRAINT "create_fan_page_soc_request_requestId_fkey" FOREIGN KEY ("requestId") REFERENCES "request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "create_fan_page_soc_request_entity" ADD CONSTRAINT "create_fan_page_soc_request_entity_createFanPageRequestId_fkey" FOREIGN KEY ("createFanPageRequestId") REFERENCES "create_fan_page_soc_request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
