import { CircleAlert, Database, Download, Loader2, Wind } from 'lucide-react'
import Link from 'next/link'
import { toast } from 'sonner'
import { Button, Card, CardContent, CardHeader, CardTitle, Skeleton } from 'ui'
import { DiffEditor } from '@/components/ui/DiffEditor'
interface DatabaseDiffPanelProps {
diffContent?: string
isLoading: boolean
error?: any
showRefreshButton?: boolean
currentBranchRef?: string
}
export const DatabaseDiffPanel = ({
diffContent,
isLoading,
error,
currentBranchRef,
}: DatabaseDiffPanelProps) => {
if (isLoading) {
return (
)
}
if (error)
return (
Error loading branch diff
Please try again in a few minutes and contact support if the problem persists.
)
if (!diffContent || diffContent.trim() === '') {
return (
No changes detected between branches
Any changes to your database schema will be shown here for review
)
}
return (
Schema Changes
}
className="mt-0"
onClick={() => {
if (!diffContent) return
const now = new Date()
const pad = (n: number) => n.toString().padStart(2, '0')
const timestamp =
now.getFullYear().toString() +
pad(now.getMonth() + 1) +
pad(now.getDate()) +
pad(now.getHours()) +
pad(now.getMinutes()) +
pad(now.getSeconds())
const filename = `${timestamp}_migration.sql`
const blob = new Blob([diffContent], { type: 'text/plain;charset=utf-8;' })
const url = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.setAttribute('download', filename)
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
window.URL.revokeObjectURL(url)
toast.success('Migration file downloaded!')
}}
>
Download as migration
)
}