-- AlterEnum
ALTER TYPE "ExternalServiceType" ADD VALUE 'PaloloLinked';

-- CreateEnum
CREATE TYPE "LinkedAccountModelName" AS ENUM ('LinkedAccount');

-- AlterTable
ALTER TABLE "FinancialAccount" ADD COLUMN     "bankName" TEXT NOT NULL DEFAULT E'';

-- CreateTable
CREATE TABLE "LinkedAccount" (
    "modelName" "LinkedAccountModelName" NOT NULL DEFAULT 'LinkedAccount',
    "id" UUID NOT NULL DEFAULT gen_random_uuid(),
    "accountNumber" TEXT NOT NULL,
    "routingNumber" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "isHidden" BOOLEAN NOT NULL DEFAULT false,
    "financialAccountId" UUID NOT NULL,

    CONSTRAINT "LinkedAccount_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "LinkedAccount" ADD CONSTRAINT "LinkedAccount_financialAccountId_fkey" FOREIGN KEY ("financialAccountId") REFERENCES "FinancialAccount"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
