mirror of
https://github.com/andwati/dokploy.git
synced 2026-12-05 00:58:47 +00: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,
|
findMountsByApplicationId,
|
||||||
findPostgresById,
|
findPostgresById,
|
||||||
findProjectById,
|
findProjectById,
|
||||||
|
getMountPath,
|
||||||
IS_CLOUD,
|
IS_CLOUD,
|
||||||
rebuildDatabase,
|
rebuildDatabase,
|
||||||
removePostgresById,
|
removePostgresById,
|
||||||
@@ -40,13 +41,6 @@ import {
|
|||||||
} from "@/server/db/schema";
|
} from "@/server/db/schema";
|
||||||
import { cancelJobs } from "@/server/utils/backup";
|
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({
|
export const postgresRouter = createTRPCRouter({
|
||||||
create: protectedProcedure
|
create: protectedProcedure
|
||||||
.input(apiCreatePostgres)
|
.input(apiCreatePostgres)
|
||||||
|
|||||||
@@ -13,6 +13,18 @@ import { TRPCError } from "@trpc/server";
|
|||||||
import { eq, getTableColumns } from "drizzle-orm";
|
import { eq, getTableColumns } from "drizzle-orm";
|
||||||
import { validUniqueServerAppName } from "./project";
|
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 type Postgres = typeof postgres.$inferSelect;
|
||||||
|
|
||||||
export const createPostgres = async (input: typeof apiCreatePostgres._type) => {
|
export const createPostgres = async (input: typeof apiCreatePostgres._type) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user