/*
  Warnings:

  - You are about to drop the `share_permition_request` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE "share_permition_request" DROP CONSTRAINT "share_permition_request_userId_fkey";

-- DropForeignKey
ALTER TABLE "share_permition_request_accounts" DROP CONSTRAINT "share_permition_request_accounts_requestId_fkey";

-- AlterTable
ALTER TABLE "account_request" ALTER COLUMN "platform" SET DEFAULT 'FACEBOOK';

-- AlterTable
ALTER TABLE "rename_request" ALTER COLUMN "platform" SET DEFAULT 'FACEBOOK';

-- AlterTable
ALTER TABLE "top_up_request" ALTER COLUMN "platform" DROP NOT NULL,
ALTER COLUMN "platform" SET DEFAULT 'FACEBOOK';

-- DropTable
DROP TABLE "share_permition_request";

-- CreateTable
CREATE TABLE "share_permission_request" (
    "id" SERIAL NOT NULL,
    "createDate" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updateDate" TIMESTAMP(3) NOT NULL,
    "note" TEXT,
    "status" "RequestStatus" NOT NULL DEFAULT 'NEW',
    "archived" BOOLEAN NOT NULL DEFAULT false,
    "requestType" "RequestType" NOT NULL DEFAULT 'SHARE_REQUEST',
    "platform" "TrafficSource" DEFAULT 'FACEBOOK',
    "userId" INTEGER NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "share_permission_request_id_key" ON "share_permission_request"("id");

-- AddForeignKey
ALTER TABLE "share_permission_request" ADD CONSTRAINT "share_permission_request_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "share_permition_request_accounts" ADD CONSTRAINT "share_permition_request_accounts_requestId_fkey" FOREIGN KEY ("requestId") REFERENCES "share_permission_request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
