-- CreateTable
CREATE TABLE "schedule_visitations" (
    "id" TEXT NOT NULL,
    "date_visit" TIMESTAMP(3) NOT NULL,
    "sales_id" TEXT NOT NULL,
    "hospital_id" TEXT NOT NULL,
    "province_id" TEXT NOT NULL,
    "notes" TEXT,
    "created_by" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "deletedAt" TIMESTAMP(3),

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

-- AddForeignKey
ALTER TABLE "schedule_visitations" ADD CONSTRAINT "schedule_visitations_hospital_id_fkey" FOREIGN KEY ("hospital_id") REFERENCES "hospitals"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "schedule_visitations" ADD CONSTRAINT "schedule_visitations_created_by_fkey" FOREIGN KEY ("created_by") REFERENCES "keycloak_users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "schedule_visitations" ADD CONSTRAINT "schedule_visitations_sales_id_fkey" FOREIGN KEY ("sales_id") REFERENCES "keycloak_users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
