mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-28 18:45:22 +02:00
refactor: move getMountPath function to services and update logic
- Moved the getMountPath function from the postgres router to the postgres service for better organization. - Updated the logic to return the correct mount path based on the PostgreSQL version, ensuring compatibility with versions below 18.
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
findMountsByApplicationId,
|
||||
findPostgresById,
|
||||
findProjectById,
|
||||
getMountPath,
|
||||
IS_CLOUD,
|
||||
rebuildDatabase,
|
||||
removePostgresById,
|
||||
@@ -40,13 +41,6 @@ import {
|
||||
} from "@/server/db/schema";
|
||||
import { cancelJobs } from "@/server/utils/backup";
|
||||
|
||||
function getMountPath(dockerImage: string): string {
|
||||
const versionMatch = dockerImage.match(/postgres:(\d+)/);
|
||||
const version = versionMatch?.[1] ? Number.parseInt(versionMatch[1], 10) : 18;
|
||||
|
||||
return `/var/lib/postgresql/${version}/data`;
|
||||
}
|
||||
|
||||
export const postgresRouter = createTRPCRouter({
|
||||
create: protectedProcedure
|
||||
.input(apiCreatePostgres)
|
||||
|
||||
@@ -13,6 +13,18 @@ import { TRPCError } from "@trpc/server";
|
||||
import { eq, getTableColumns } from "drizzle-orm";
|
||||
import { validUniqueServerAppName } from "./project";
|
||||
|
||||
export function getMountPath(dockerImage: string): string {
|
||||
const versionMatch = dockerImage.match(/postgres:(\d+)/);
|
||||
|
||||
if (versionMatch?.[1]) {
|
||||
const version = Number.parseInt(versionMatch[1], 10);
|
||||
if (version >= 18) {
|
||||
return `/var/lib/postgresql/${version}/data`;
|
||||
}
|
||||
}
|
||||
return "/var/lib/postgresql/data";
|
||||
}
|
||||
|
||||
export type Postgres = typeof postgres.$inferSelect;
|
||||
|
||||
export const createPostgres = async (input: typeof apiCreatePostgres._type) => {
|
||||
|
||||
Reference in New Issue
Block a user