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:
Mauricio Siu
2025-11-26 01:20:40 -05:00
parent d08fdeb939
commit 23b235303c
2 changed files with 13 additions and 7 deletions
+1 -7
View File
@@ -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)