add mysql, mariadb, postgresql, sqlite volumes support

This commit is contained in:
Renan Bernordi
2025-11-15 23:32:26 -03:00
parent c0bef7f65e
commit eb28667d90
15 changed files with 1022 additions and 25 deletions

View File

@@ -1,5 +1,6 @@
import { VOLUME_MOUNT_BASE } from "../../core/constants";
import type { Volume } from "../../db/schema";
import type { BackendConfig } from "~/schemas/volumes";
export const getVolumePath = (volume: Volume) => {
if (volume.config.backend === "directory") {
@@ -8,3 +9,37 @@ export const getVolumePath = (volume: Volume) => {
return `${VOLUME_MOUNT_BASE}/${volume.name}/_data`;
};
/**
* Check if a volume is a database volume
*/
export const isDatabaseVolume = (volume: Volume): boolean => {
return ["mariadb", "mysql", "postgres", "sqlite"].includes(volume.config.backend);
};
/**
* Check if a backend config is a database backend
*/
export const isDatabaseBackend = (config: BackendConfig): boolean => {
return ["mariadb", "mysql", "postgres", "sqlite"].includes(config.backend);
};
/**
* Get the dump directory path for a database volume
*/
export const getDumpPath = (volume: Volume): string => {
return `${VOLUME_MOUNT_BASE}/${volume.name}/dumps`;
};
/**
* Get the dump file path for a database volume backup
*/
export const getDumpFilePath = (volume: Volume, timestamp: number): string => {
const dumpDir = getDumpPath(volume);
const extension = volume.config.backend === "postgres" &&
volume.config.backend === "postgres" &&
(volume.config as Extract<BackendConfig, { backend: "postgres" }>).dumpFormat !== "plain"
? "dump"
: "sql";
return `${dumpDir}/${volume.name}-${timestamp}.${extension}`;
};