Implementing Unpooled Connections for Prisma CLI and Adding Change Log to Settings
TL;DR:
I updated the Prisma configuration to use unpooled connections for the Prisma CLI, enhancing performance during migrations and db pushes. Additionally, I implemented a change log feature in the Settings dashboard, enabling users to track synchronization history.
The Problem
When running Prisma CLI commands like migrate and db push, I noticed that the pooled connection was causing delays. The Prisma documentation suggests using unpooled connections for these operations to improve performance. Furthermore, I wanted to enhance the Settings dashboard by adding a change log feature that displays the synchronization history.
What I Tried First
Initially, I attempted to configure Prisma to use a pooled connection for all operations, but this didn't yield the desired performance for CLI commands. I then explored using an unpooled connection specifically for migrations and db pushes.
The Implementation
Using Unpooled Connections for Prisma CLI
To implement unpooled connections for Prisma CLI commands, I modified the prisma.config.ts file:
// prisma.config.ts
import { defineConfig } from "prisma/config";
export default defineConfig({
// ... other configurations ...
datasource: {
url: process.env.DATABASE_URL,
// Use unpooled connection for CLI commands
connect: {
pool: false,
},
},
});
This change ensures that Prisma CLI commands use a direct, unpooled connection, improving performance.
Adding Change Log to Settings
To add the change log feature to the Settings dashboard, I made the following changes:
Updating Prisma Schema
// prisma/schema.prisma
model SyncLog {
id String @id @default(cuid())
startedAt DateTime @default(now())
duration Int?
message String?
changes DeviceHistory[]
}
model DeviceHistory {
id String @id @default(cuid())
deviceId String
// ... other fields ...
}
Implementing Sync History Log Component
// src/features/sync/SyncHistoryLog.tsx
"use client";
import { useState } from "react";
import { ChevronDown, ChevronRight } from "lucide-react";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
const SyncHistoryLog = () => {
const [expanded, setExpanded] = useState(false);
const handleToggle = () => {
setExpanded(!expanded);
};
return (
<Card>
<CardHeader>
<CardTitle>Sync History Log</CardTitle>
<button onClick={handleToggle}>
{expanded ? <ChevronDown /> : <ChevronRight />}
</button>
</CardHeader>
{expanded && (
<CardContent>
{/* Render sync history log details */}
</CardContent>
)}
</Card>
);
};
export default SyncHistoryLog;
Updating Settings Page
// src/app/(dashboard)/settings/page.tsx
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { SyncPanel } from "@/features/sync/SyncPanel";
import { SyncHistoryLog } from "@/features/sync/SyncHistoryLog";
const SettingsPage = () => {
return (
<div>
<Card>
<CardHeader>
<CardTitle>Settings</CardTitle>
</CardHeader>
<CardContent>
<SyncPanel />
<SyncHistoryLog />
</CardContent>
</Card>
</div>
);
};
export default SettingsPage;
Key Takeaway
When optimizing database interactions, consider using unpooled connections for CLI operations to improve performance. Additionally, implementing a change log feature can enhance user experience by providing transparency into synchronization history.
What's Next
In the next iteration, I plan to integrate the change log feature with the Google Sheets sync functionality to provide a more comprehensive view of synchronization history.
vibecoding #buildinpublic #prisma #unpooledconnections #change log #settingsdashboard
Part of my Build in Public series — sharing the real process of building SaaS projects from Playa del Carmen, México.
Repo: zaerohell/greenview · 2026-07-09
#playadev #buildinpublic
Top comments (0)