mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-20 19:18:45 +00:00
feat(libsql): introduce libsql service schema and update related tables
- Created a new SQL type for 'libsql' and added it to the serviceType enum. - Established a 'libsql' table with necessary fields and constraints. - Updated existing tables (backup, mount, volume_backup) to include foreign key references to 'libsql'. - Adjusted the mount schema to incorporate 'libsql' as a valid service type, enhancing service management capabilities.
This commit is contained in:
+5
-7
@@ -1,4 +1,6 @@
|
|||||||
CREATE TYPE "public"."sqldNode" AS ENUM('primary', 'replica');--> statement-breakpoint
|
CREATE TYPE "public"."sqldNode" AS ENUM('primary', 'replica');--> statement-breakpoint
|
||||||
|
ALTER TYPE "public"."databaseType" ADD VALUE 'libsql';--> statement-breakpoint
|
||||||
|
ALTER TYPE "public"."serviceType" ADD VALUE 'libsql';--> statement-breakpoint
|
||||||
CREATE TABLE "libsql" (
|
CREATE TABLE "libsql" (
|
||||||
"libsqlId" text PRIMARY KEY NOT NULL,
|
"libsqlId" text PRIMARY KEY NOT NULL,
|
||||||
"name" text NOT NULL,
|
"name" text NOT NULL,
|
||||||
@@ -9,8 +11,6 @@ CREATE TABLE "libsql" (
|
|||||||
"sqldNode" "sqldNode" DEFAULT 'primary' NOT NULL,
|
"sqldNode" "sqldNode" DEFAULT 'primary' NOT NULL,
|
||||||
"sqldPrimaryUrl" text,
|
"sqldPrimaryUrl" text,
|
||||||
"enableNamespaces" boolean DEFAULT false NOT NULL,
|
"enableNamespaces" boolean DEFAULT false NOT NULL,
|
||||||
"enableBottomlessReplication" boolean DEFAULT false NOT NULL,
|
|
||||||
"bottomlessReplicationDestinationId" text,
|
|
||||||
"dockerImage" text NOT NULL,
|
"dockerImage" text NOT NULL,
|
||||||
"command" text,
|
"command" text,
|
||||||
"env" text,
|
"env" text,
|
||||||
@@ -37,13 +37,11 @@ CREATE TABLE "libsql" (
|
|||||||
CONSTRAINT "libsql_appName_unique" UNIQUE("appName")
|
CONSTRAINT "libsql_appName_unique" UNIQUE("appName")
|
||||||
);
|
);
|
||||||
--> statement-breakpoint
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "backup" ADD COLUMN "libsqlId" text;--> statement-breakpoint
|
||||||
ALTER TABLE "mount" ADD COLUMN "libsqlId" text;--> statement-breakpoint
|
ALTER TABLE "mount" ADD COLUMN "libsqlId" text;--> statement-breakpoint
|
||||||
ALTER TABLE "volume_backup" ADD COLUMN "libsqlId" text;--> statement-breakpoint
|
ALTER TABLE "volume_backup" ADD COLUMN "libsqlId" text;--> statement-breakpoint
|
||||||
ALTER TABLE "libsql" ADD CONSTRAINT "libsql_bottomlessReplicationDestinationId_destination_destinationId_fk" FOREIGN KEY ("bottomlessReplicationDestinationId") REFERENCES "public"."destination"("destinationId") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "libsql" ADD CONSTRAINT "libsql_environmentId_environment_environmentId_fk" FOREIGN KEY ("environmentId") REFERENCES "public"."environment"("environmentId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
ALTER TABLE "libsql" ADD CONSTRAINT "libsql_environmentId_environment_environmentId_fk" FOREIGN KEY ("environmentId") REFERENCES "public"."environment"("environmentId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
ALTER TABLE "libsql" ADD CONSTRAINT "libsql_serverId_server_serverId_fk" FOREIGN KEY ("serverId") REFERENCES "public"."server"("serverId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
ALTER TABLE "libsql" ADD CONSTRAINT "libsql_serverId_server_serverId_fk" FOREIGN KEY ("serverId") REFERENCES "public"."server"("serverId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "backup" ADD CONSTRAINT "backup_libsqlId_libsql_libsqlId_fk" FOREIGN KEY ("libsqlId") REFERENCES "public"."libsql"("libsqlId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
ALTER TABLE "mount" ADD CONSTRAINT "mount_libsqlId_libsql_libsqlId_fk" FOREIGN KEY ("libsqlId") REFERENCES "public"."libsql"("libsqlId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
ALTER TABLE "mount" ADD CONSTRAINT "mount_libsqlId_libsql_libsqlId_fk" FOREIGN KEY ("libsqlId") REFERENCES "public"."libsql"("libsqlId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
ALTER TABLE "volume_backup" ADD CONSTRAINT "volume_backup_libsqlId_libsql_libsqlId_fk" FOREIGN KEY ("libsqlId") REFERENCES "public"."libsql"("libsqlId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
ALTER TABLE "volume_backup" ADD CONSTRAINT "volume_backup_libsqlId_libsql_libsqlId_fk" FOREIGN KEY ("libsqlId") REFERENCES "public"."libsql"("libsqlId") ON DELETE cascade ON UPDATE no action;
|
||||||
ALTER TABLE "mount" DROP COLUMN "serviceType";--> statement-breakpoint
|
|
||||||
ALTER TABLE "volume_backup" DROP COLUMN "serviceType";--> statement-breakpoint
|
|
||||||
DROP TYPE "public"."serviceType";
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
ALTER TYPE "public"."databaseType" ADD VALUE 'libsql';--> statement-breakpoint
|
|
||||||
ALTER TABLE "libsql" DROP CONSTRAINT "libsql_bottomlessReplicationDestinationId_destination_destinationId_fk";
|
|
||||||
--> statement-breakpoint
|
|
||||||
ALTER TABLE "backup" ADD COLUMN "libsqlId" text;--> statement-breakpoint
|
|
||||||
ALTER TABLE "backup" ADD CONSTRAINT "backup_libsqlId_libsql_libsqlId_fk" FOREIGN KEY ("libsqlId") REFERENCES "public"."libsql"("libsqlId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
||||||
ALTER TABLE "libsql" DROP COLUMN "enableBottomlessReplication";--> statement-breakpoint
|
|
||||||
ALTER TABLE "libsql" DROP COLUMN "bottomlessReplicationDestinationId";
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"id": "f040f17d-3acf-42ce-b49a-ae4c0d4b7300",
|
"id": "72bb48c9-d724-458b-bd91-3ae50e9afe0f",
|
||||||
"prevId": "68c71185-6e91-4b8d-8f91-795457e75ab2",
|
"prevId": "68c71185-6e91-4b8d-8f91-795457e75ab2",
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"dialect": "postgresql",
|
"dialect": "postgresql",
|
||||||
@@ -1961,6 +1961,12 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": false
|
"notNull": false
|
||||||
},
|
},
|
||||||
|
"libsqlId": {
|
||||||
|
"name": "libsqlId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
"userId": {
|
"userId": {
|
||||||
"name": "userId",
|
"name": "userId",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -2054,6 +2060,19 @@
|
|||||||
"onDelete": "cascade",
|
"onDelete": "cascade",
|
||||||
"onUpdate": "no action"
|
"onUpdate": "no action"
|
||||||
},
|
},
|
||||||
|
"backup_libsqlId_libsql_libsqlId_fk": {
|
||||||
|
"name": "backup_libsqlId_libsql_libsqlId_fk",
|
||||||
|
"tableFrom": "backup",
|
||||||
|
"tableTo": "libsql",
|
||||||
|
"columnsFrom": [
|
||||||
|
"libsqlId"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"libsqlId"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
"backup_userId_user_id_fk": {
|
"backup_userId_user_id_fk": {
|
||||||
"name": "backup_userId_user_id_fk",
|
"name": "backup_userId_user_id_fk",
|
||||||
"tableFrom": "backup",
|
"tableFrom": "backup",
|
||||||
@@ -3624,19 +3643,6 @@
|
|||||||
"notNull": true,
|
"notNull": true,
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"enableBottomlessReplication": {
|
|
||||||
"name": "enableBottomlessReplication",
|
|
||||||
"type": "boolean",
|
|
||||||
"primaryKey": false,
|
|
||||||
"notNull": true,
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"bottomlessReplicationDestinationId": {
|
|
||||||
"name": "bottomlessReplicationDestinationId",
|
|
||||||
"type": "text",
|
|
||||||
"primaryKey": false,
|
|
||||||
"notNull": false
|
|
||||||
},
|
|
||||||
"dockerImage": {
|
"dockerImage": {
|
||||||
"name": "dockerImage",
|
"name": "dockerImage",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -3781,19 +3787,6 @@
|
|||||||
},
|
},
|
||||||
"indexes": {},
|
"indexes": {},
|
||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"libsql_bottomlessReplicationDestinationId_destination_destinationId_fk": {
|
|
||||||
"name": "libsql_bottomlessReplicationDestinationId_destination_destinationId_fk",
|
|
||||||
"tableFrom": "libsql",
|
|
||||||
"tableTo": "destination",
|
|
||||||
"columnsFrom": [
|
|
||||||
"bottomlessReplicationDestinationId"
|
|
||||||
],
|
|
||||||
"columnsTo": [
|
|
||||||
"destinationId"
|
|
||||||
],
|
|
||||||
"onDelete": "set null",
|
|
||||||
"onUpdate": "no action"
|
|
||||||
},
|
|
||||||
"libsql_environmentId_environment_environmentId_fk": {
|
"libsql_environmentId_environment_environmentId_fk": {
|
||||||
"name": "libsql_environmentId_environment_environmentId_fk",
|
"name": "libsql_environmentId_environment_environmentId_fk",
|
||||||
"tableFrom": "libsql",
|
"tableFrom": "libsql",
|
||||||
@@ -4369,6 +4362,14 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": false
|
"notNull": false
|
||||||
},
|
},
|
||||||
|
"serviceType": {
|
||||||
|
"name": "serviceType",
|
||||||
|
"type": "serviceType",
|
||||||
|
"typeSchema": "public",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "'application'"
|
||||||
|
},
|
||||||
"mountPath": {
|
"mountPath": {
|
||||||
"name": "mountPath",
|
"name": "mountPath",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -7562,6 +7563,14 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
"serviceType": {
|
||||||
|
"name": "serviceType",
|
||||||
|
"type": "serviceType",
|
||||||
|
"typeSchema": "public",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "'application'"
|
||||||
|
},
|
||||||
"appName": {
|
"appName": {
|
||||||
"name": "appName",
|
"name": "appName",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -7950,7 +7959,8 @@
|
|||||||
"mariadb",
|
"mariadb",
|
||||||
"mysql",
|
"mysql",
|
||||||
"mongo",
|
"mongo",
|
||||||
"web-server"
|
"web-server",
|
||||||
|
"libsql"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"public.composeType": {
|
"public.composeType": {
|
||||||
@@ -8011,6 +8021,20 @@
|
|||||||
"file"
|
"file"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"public.serviceType": {
|
||||||
|
"name": "serviceType",
|
||||||
|
"schema": "public",
|
||||||
|
"values": [
|
||||||
|
"application",
|
||||||
|
"postgres",
|
||||||
|
"mysql",
|
||||||
|
"mariadb",
|
||||||
|
"mongo",
|
||||||
|
"redis",
|
||||||
|
"compose",
|
||||||
|
"libsql"
|
||||||
|
]
|
||||||
|
},
|
||||||
"public.notificationType": {
|
"public.notificationType": {
|
||||||
"name": "notificationType",
|
"name": "notificationType",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1076,15 +1076,8 @@
|
|||||||
{
|
{
|
||||||
"idx": 153,
|
"idx": 153,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1773940853496,
|
"when": 1774303955927,
|
||||||
"tag": "0153_even_morlocks",
|
"tag": "0153_green_boomerang",
|
||||||
"breakpoints": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idx": 154,
|
|
||||||
"version": "7",
|
|
||||||
"when": 1773942481550,
|
|
||||||
"tag": "0154_tan_living_mummy",
|
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
deleteMount,
|
deleteMount,
|
||||||
findApplicationById,
|
findApplicationById,
|
||||||
findComposeById,
|
findComposeById,
|
||||||
|
findLibsqlById,
|
||||||
findMariadbById,
|
findMariadbById,
|
||||||
findMongoById,
|
findMongoById,
|
||||||
findMountById,
|
findMountById,
|
||||||
@@ -13,7 +14,7 @@ import {
|
|||||||
getServiceContainer,
|
getServiceContainer,
|
||||||
updateMount,
|
updateMount,
|
||||||
} from "@dokploy/server";
|
} from "@dokploy/server";
|
||||||
import type { ServiceType } from "@dokploy/server/services/mount";
|
import type { ServiceType } from "@dokploy/server/db/schema/mount";
|
||||||
import {
|
import {
|
||||||
checkServiceAccess,
|
checkServiceAccess,
|
||||||
checkServicePermissionAndAccess,
|
checkServicePermissionAndAccess,
|
||||||
@@ -63,6 +64,10 @@ async function getServiceOrganizationId(
|
|||||||
const compose = await findComposeById(serviceId);
|
const compose = await findComposeById(serviceId);
|
||||||
return compose?.environment?.project?.organizationId ?? null;
|
return compose?.environment?.project?.organizationId ?? null;
|
||||||
}
|
}
|
||||||
|
case "libsql": {
|
||||||
|
const libsql = await findLibsqlById(serviceId);
|
||||||
|
return libsql?.environment?.project?.organizationId ?? null;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -169,7 +174,6 @@ export const mountRouter = createTRPCRouter({
|
|||||||
listByServiceId: protectedProcedure
|
listByServiceId: protectedProcedure
|
||||||
.input(apiFindMountByApplicationId)
|
.input(apiFindMountByApplicationId)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
console.log("input", input);
|
|
||||||
await checkServiceAccess(ctx, input.serviceId, "read");
|
await checkServiceAccess(ctx, input.serviceId, "read");
|
||||||
const organizationId = await getServiceOrganizationId(
|
const organizationId = await getServiceOrganizationId(
|
||||||
input.serviceId,
|
input.serviceId,
|
||||||
|
|||||||
@@ -12,6 +12,19 @@ import { mysql } from "./mysql";
|
|||||||
import { postgres } from "./postgres";
|
import { postgres } from "./postgres";
|
||||||
import { redis } from "./redis";
|
import { redis } from "./redis";
|
||||||
|
|
||||||
|
export const serviceType = pgEnum("serviceType", [
|
||||||
|
"application",
|
||||||
|
"postgres",
|
||||||
|
"mysql",
|
||||||
|
"mariadb",
|
||||||
|
"mongo",
|
||||||
|
"redis",
|
||||||
|
"compose",
|
||||||
|
"libsql",
|
||||||
|
]);
|
||||||
|
|
||||||
|
export type ServiceType = (typeof serviceType.enumValues)[number];
|
||||||
|
|
||||||
export const mountType = pgEnum("mountType", ["bind", "volume", "file"]);
|
export const mountType = pgEnum("mountType", ["bind", "volume", "file"]);
|
||||||
|
|
||||||
export const mounts = pgTable("mount", {
|
export const mounts = pgTable("mount", {
|
||||||
@@ -24,6 +37,7 @@ export const mounts = pgTable("mount", {
|
|||||||
volumeName: text("volumeName"),
|
volumeName: text("volumeName"),
|
||||||
filePath: text("filePath"),
|
filePath: text("filePath"),
|
||||||
content: text("content"),
|
content: text("content"),
|
||||||
|
serviceType: serviceType("serviceType").notNull().default("application"),
|
||||||
mountPath: text("mountPath").notNull(),
|
mountPath: text("mountPath").notNull(),
|
||||||
applicationId: text("applicationId").references(
|
applicationId: text("applicationId").references(
|
||||||
() => applications.applicationId,
|
() => applications.applicationId,
|
||||||
@@ -96,6 +110,16 @@ const createSchema = createInsertSchema(mounts, {
|
|||||||
mountPath: z.string().min(1),
|
mountPath: z.string().min(1),
|
||||||
mountId: z.string().optional(),
|
mountId: z.string().optional(),
|
||||||
filePath: z.string().optional(),
|
filePath: z.string().optional(),
|
||||||
|
serviceType: z.enum([
|
||||||
|
"application",
|
||||||
|
"postgres",
|
||||||
|
"mysql",
|
||||||
|
"mariadb",
|
||||||
|
"mongo",
|
||||||
|
"redis",
|
||||||
|
"compose",
|
||||||
|
"libsql",
|
||||||
|
]),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiCreateMount = createSchema
|
export const apiCreateMount = createSchema
|
||||||
@@ -106,19 +130,10 @@ export const apiCreateMount = createSchema
|
|||||||
content: true,
|
content: true,
|
||||||
mountPath: true,
|
mountPath: true,
|
||||||
filePath: true,
|
filePath: true,
|
||||||
|
serviceType: true,
|
||||||
})
|
})
|
||||||
.extend({
|
.extend({
|
||||||
serviceId: z.string().min(1),
|
serviceId: z.string().min(1),
|
||||||
serviceType: z.enum([
|
|
||||||
"application",
|
|
||||||
"postgres",
|
|
||||||
"mysql",
|
|
||||||
"mariadb",
|
|
||||||
"mongo",
|
|
||||||
"redis",
|
|
||||||
"compose",
|
|
||||||
"libsql",
|
|
||||||
]),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiFindOneMount = z.object({
|
export const apiFindOneMount = z.object({
|
||||||
@@ -134,19 +149,14 @@ export const apiRemoveMount = createSchema
|
|||||||
// })
|
// })
|
||||||
.required();
|
.required();
|
||||||
|
|
||||||
export const apiFindMountByApplicationId = z.object({
|
export const apiFindMountByApplicationId = createSchema
|
||||||
serviceId: z.string().min(1),
|
.pick({
|
||||||
serviceType: z.enum([
|
serviceType: true,
|
||||||
"application",
|
})
|
||||||
"postgres",
|
.required()
|
||||||
"mysql",
|
.extend({
|
||||||
"mariadb",
|
serviceId: z.string().min(1),
|
||||||
"mongo",
|
});
|
||||||
"redis",
|
|
||||||
"compose",
|
|
||||||
"libsql",
|
|
||||||
]),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const apiUpdateMount = createSchema.partial().extend({
|
export const apiUpdateMount = createSchema.partial().extend({
|
||||||
mountId: z.string().min(1),
|
mountId: z.string().min(1),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { relations } from "drizzle-orm";
|
import { relations } from "drizzle-orm";
|
||||||
import { boolean, integer, pgTable, text } from "drizzle-orm/pg-core";
|
import { boolean, integer, pgTable, text } from "drizzle-orm/pg-core";
|
||||||
|
import { serviceType } from "./mount";
|
||||||
import { createInsertSchema } from "drizzle-zod";
|
import { createInsertSchema } from "drizzle-zod";
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
@@ -23,6 +24,7 @@ export const volumeBackups = pgTable("volume_backup", {
|
|||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
volumeName: text("volumeName").notNull(),
|
volumeName: text("volumeName").notNull(),
|
||||||
prefix: text("prefix").notNull(),
|
prefix: text("prefix").notNull(),
|
||||||
|
serviceType: serviceType("serviceType").notNull().default("application"),
|
||||||
appName: text("appName")
|
appName: text("appName")
|
||||||
.notNull()
|
.notNull()
|
||||||
.$defaultFn(() => generateAppName("volumeBackup")),
|
.$defaultFn(() => generateAppName("volumeBackup")),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { db } from "@dokploy/server/db";
|
|||||||
import {
|
import {
|
||||||
type apiCreateMount,
|
type apiCreateMount,
|
||||||
mounts,
|
mounts,
|
||||||
|
type ServiceType,
|
||||||
} from "@dokploy/server/db/schema";
|
} from "@dokploy/server/db/schema";
|
||||||
import {
|
import {
|
||||||
createFile,
|
createFile,
|
||||||
@@ -19,16 +20,6 @@ import { TRPCError } from "@trpc/server";
|
|||||||
import { eq, type SQL, sql } from "drizzle-orm";
|
import { eq, type SQL, sql } from "drizzle-orm";
|
||||||
import type { z } from "zod";
|
import type { z } from "zod";
|
||||||
|
|
||||||
export type ServiceType =
|
|
||||||
| "application"
|
|
||||||
| "compose"
|
|
||||||
| "libsql"
|
|
||||||
| "mariadb"
|
|
||||||
| "mongo"
|
|
||||||
| "mysql"
|
|
||||||
| "postgres"
|
|
||||||
| "redis";
|
|
||||||
|
|
||||||
export type Mount = typeof mounts.$inferSelect;
|
export type Mount = typeof mounts.$inferSelect;
|
||||||
|
|
||||||
export const createMount = async (input: z.infer<typeof apiCreateMount>) => {
|
export const createMount = async (input: z.infer<typeof apiCreateMount>) => {
|
||||||
@@ -361,38 +352,38 @@ export const getBaseFilesPath = async (mountId: string) => {
|
|||||||
let appName = "";
|
let appName = "";
|
||||||
let directoryPath = "";
|
let directoryPath = "";
|
||||||
|
|
||||||
if (mount.applicationId && mount.application) {
|
if (mount.serviceType === "application" && mount.application) {
|
||||||
const { APPLICATIONS_PATH } = paths(!!mount.application.serverId);
|
const { APPLICATIONS_PATH } = paths(!!mount.application.serverId);
|
||||||
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
||||||
appName = mount.application.appName;
|
appName = mount.application.appName;
|
||||||
} else if (mount.composeId && mount.compose) {
|
} else if (mount.serviceType === "postgres" && mount.postgres) {
|
||||||
const { COMPOSE_PATH } = paths(!!mount.compose.serverId);
|
|
||||||
appName = mount.compose.appName;
|
|
||||||
absoluteBasePath = path.resolve(COMPOSE_PATH);
|
|
||||||
} else if (mount.libsqlId && mount.libsql) {
|
|
||||||
const { APPLICATIONS_PATH } = paths(!!mount.libsql.serverId);
|
|
||||||
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
|
||||||
appName = mount.libsql.appName;
|
|
||||||
} else if (mount.mariadbId && mount.mariadb) {
|
|
||||||
const { APPLICATIONS_PATH } = paths(!!mount.mariadb.serverId);
|
|
||||||
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
|
||||||
appName = mount.mariadb.appName;
|
|
||||||
} else if (mount.mongoId && mount.mongo) {
|
|
||||||
const { APPLICATIONS_PATH } = paths(!!mount.mongo.serverId);
|
|
||||||
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
|
||||||
appName = mount.mongo.appName;
|
|
||||||
} else if (mount.mysqlId && mount.mysql) {
|
|
||||||
const { APPLICATIONS_PATH } = paths(!!mount.mysql.serverId);
|
|
||||||
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
|
||||||
appName = mount.mysql.appName;
|
|
||||||
} else if (mount.postgresId && mount.postgres) {
|
|
||||||
const { APPLICATIONS_PATH } = paths(!!mount.postgres.serverId);
|
const { APPLICATIONS_PATH } = paths(!!mount.postgres.serverId);
|
||||||
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
||||||
appName = mount.postgres.appName;
|
appName = mount.postgres.appName;
|
||||||
} else if (mount.redisId && mount.redis) {
|
} else if (mount.serviceType === "mariadb" && mount.mariadb) {
|
||||||
|
const { APPLICATIONS_PATH } = paths(!!mount.mariadb.serverId);
|
||||||
|
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
||||||
|
appName = mount.mariadb.appName;
|
||||||
|
} else if (mount.serviceType === "mongo" && mount.mongo) {
|
||||||
|
const { APPLICATIONS_PATH } = paths(!!mount.mongo.serverId);
|
||||||
|
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
||||||
|
appName = mount.mongo.appName;
|
||||||
|
} else if (mount.serviceType === "mysql" && mount.mysql) {
|
||||||
|
const { APPLICATIONS_PATH } = paths(!!mount.mysql.serverId);
|
||||||
|
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
||||||
|
appName = mount.mysql.appName;
|
||||||
|
} else if (mount.serviceType === "redis" && mount.redis) {
|
||||||
const { APPLICATIONS_PATH } = paths(!!mount.redis.serverId);
|
const { APPLICATIONS_PATH } = paths(!!mount.redis.serverId);
|
||||||
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
||||||
appName = mount.redis.appName;
|
appName = mount.redis.appName;
|
||||||
|
} else if (mount.serviceType === "compose" && mount.compose) {
|
||||||
|
const { COMPOSE_PATH } = paths(!!mount.compose.serverId);
|
||||||
|
appName = mount.compose.appName;
|
||||||
|
absoluteBasePath = path.resolve(COMPOSE_PATH);
|
||||||
|
} else if (mount.serviceType === "libsql" && mount.libsql) {
|
||||||
|
const { APPLICATIONS_PATH } = paths(!!mount.libsql.serverId);
|
||||||
|
absoluteBasePath = path.resolve(APPLICATIONS_PATH);
|
||||||
|
appName = mount.libsql.appName;
|
||||||
}
|
}
|
||||||
directoryPath = path.join(absoluteBasePath, appName, "files");
|
directoryPath = path.join(absoluteBasePath, appName, "files");
|
||||||
|
|
||||||
@@ -401,30 +392,30 @@ export const getBaseFilesPath = async (mountId: string) => {
|
|||||||
|
|
||||||
type MountNested = Awaited<ReturnType<typeof findMountById>>;
|
type MountNested = Awaited<ReturnType<typeof findMountById>>;
|
||||||
export const getServerId = async (mount: MountNested) => {
|
export const getServerId = async (mount: MountNested) => {
|
||||||
if (mount.applicationId && mount?.application?.serverId) {
|
if (mount.serviceType === "application" && mount?.application?.serverId) {
|
||||||
return mount.application.serverId;
|
return mount.application.serverId;
|
||||||
}
|
}
|
||||||
if (mount.composeId && mount?.compose?.serverId) {
|
if (mount.serviceType === "postgres" && mount?.postgres?.serverId) {
|
||||||
return mount.compose.serverId;
|
|
||||||
}
|
|
||||||
if (mount.libsqlId && mount?.libsql?.serverId) {
|
|
||||||
return mount.libsql.serverId;
|
|
||||||
}
|
|
||||||
if (mount.mariadbId && mount?.mariadb?.serverId) {
|
|
||||||
return mount.mariadb.serverId;
|
|
||||||
}
|
|
||||||
if (mount.mongoId && mount?.mongo?.serverId) {
|
|
||||||
return mount.mongo.serverId;
|
|
||||||
}
|
|
||||||
if (mount.mysqlId && mount?.mysql?.serverId) {
|
|
||||||
return mount.mysql.serverId;
|
|
||||||
}
|
|
||||||
if (mount.postgresId && mount?.postgres?.serverId) {
|
|
||||||
return mount.postgres.serverId;
|
return mount.postgres.serverId;
|
||||||
}
|
}
|
||||||
if (mount.redisId && mount?.redis?.serverId) {
|
if (mount.serviceType === "mariadb" && mount?.mariadb?.serverId) {
|
||||||
|
return mount.mariadb.serverId;
|
||||||
|
}
|
||||||
|
if (mount.serviceType === "mongo" && mount?.mongo?.serverId) {
|
||||||
|
return mount.mongo.serverId;
|
||||||
|
}
|
||||||
|
if (mount.serviceType === "mysql" && mount?.mysql?.serverId) {
|
||||||
|
return mount.mysql.serverId;
|
||||||
|
}
|
||||||
|
if (mount.serviceType === "redis" && mount?.redis?.serverId) {
|
||||||
return mount.redis.serverId;
|
return mount.redis.serverId;
|
||||||
}
|
}
|
||||||
|
if (mount.serviceType === "compose" && mount?.compose?.serverId) {
|
||||||
|
return mount.compose.serverId;
|
||||||
|
}
|
||||||
|
if (mount.serviceType === "libsql" && mount?.libsql?.serverId) {
|
||||||
|
return mount.libsql.serverId;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const restoreComposeBackup = async (
|
|||||||
rcloneCommand = `rclone copy ${rcloneFlags.join(" ")} "${backupPath}"`;
|
rcloneCommand = `rclone copy ${rcloneFlags.join(" ")} "${backupPath}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let credentials: DatabaseCredentials;
|
let credentials: DatabaseCredentials = {};
|
||||||
|
|
||||||
switch (backupInput.databaseType) {
|
switch (backupInput.databaseType) {
|
||||||
case "postgres":
|
case "postgres":
|
||||||
|
|||||||
Reference in New Issue
Block a user