/*
  Warnings:

  - You are about to drop the column `accountId` on the `account_trouble_approve_request_entity` table. All the data in the column will be lost.
  - Added the required column `bmExternalId` to the `account_trouble_approve_request_entity` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE "account_trouble_approve_request_entity" DROP CONSTRAINT "account_trouble_approve_request_entity_accountId_fkey";

-- AlterTable
ALTER TABLE "account_trouble_approve_request_entity" DROP COLUMN "accountId",
ADD COLUMN     "bmExternalId" TEXT NOT NULL;

-- CreateTable
CREATE TABLE "account_trouble_approve_request_entity_account" (
    "id" SERIAL NOT NULL,
    "accountTroubleRequestEntityId" INTEGER NOT NULL,
    "accountId" INTEGER NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "account_trouble_approve_request_entity_account_id_key" ON "account_trouble_approve_request_entity_account"("id");

-- AddForeignKey
ALTER TABLE "account_trouble_approve_request_entity_account" ADD CONSTRAINT "account_trouble_approve_request_entity_account_accountTrou_fkey" FOREIGN KEY ("accountTroubleRequestEntityId") REFERENCES "account_trouble_approve_request_entity"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

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