mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
add mysql, mariadb, postgresql, sqlite volumes support
This commit is contained in:
@@ -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}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user