import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { api } from "@/utils/api"; import { AlertTriangle, DatabaseIcon } from "lucide-react"; import { toast } from "sonner"; interface Props { id: string; type: "postgres" | "mysql" | "mariadb" | "mongo" | "redis"; } export const RebuildDatabase = ({ id, type }: Props) => { const utils = api.useUtils(); const mutationMap = { postgres: () => api.postgres.rebuild.useMutation(), mysql: () => api.mysql.rebuild.useMutation(), mariadb: () => api.mariadb.rebuild.useMutation(), mongo: () => api.mongo.rebuild.useMutation(), redis: () => api.redis.rebuild.useMutation(), }; const { mutateAsync, isLoading } = mutationMap[type](); const handleRebuild = async () => { try { await mutateAsync({ postgresId: type === "postgres" ? id : "", mysqlId: type === "mysql" ? id : "", mariadbId: type === "mariadb" ? id : "", mongoId: type === "mongo" ? id : "", redisId: type === "redis" ? id : "", }); toast.success("Database rebuilt successfully"); await utils.invalidate(); } catch (error) { toast.error("Error rebuilding database", { description: error instanceof Error ? error.message : "Unknown error", }); } }; return ( Danger Zone

Rebuild Database

This action will completely reset your database to its initial state. All data, tables, and configurations will be removed.

Are you absolutely sure?

This action will:

  • Stop the current database service
  • Delete all existing data and volumes
  • Reset to the default configuration
  • Restart the service with a clean state

This action cannot be undone.

Cancel
); };