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:
Mauricio Siu
2026-03-23 16:14:37 -06:00
parent 116e9d85b7
commit 4b6f2c84ac
10 changed files with 143 additions and 8266 deletions

View File

@@ -1,4 +1,6 @@
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" (
"libsqlId" text PRIMARY KEY NOT NULL,
"name" text NOT NULL,
@@ -9,8 +11,6 @@ CREATE TABLE "libsql" (
"sqldNode" "sqldNode" DEFAULT 'primary' NOT NULL,
"sqldPrimaryUrl" text,
"enableNamespaces" boolean DEFAULT false NOT NULL,
"enableBottomlessReplication" boolean DEFAULT false NOT NULL,
"bottomlessReplicationDestinationId" text,
"dockerImage" text NOT NULL,
"command" text,
"env" text,
@@ -37,13 +37,11 @@ CREATE TABLE "libsql" (
CONSTRAINT "libsql_appName_unique" UNIQUE("appName")
);
--> statement-breakpoint
ALTER TABLE "backup" 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 "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_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 "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 "mount" DROP COLUMN "serviceType";--> statement-breakpoint
ALTER TABLE "volume_backup" DROP COLUMN "serviceType";--> statement-breakpoint
DROP TYPE "public"."serviceType";
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;

View File

@@ -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";

View File

@@ -1,5 +1,5 @@
{
"id": "f040f17d-3acf-42ce-b49a-ae4c0d4b7300",
"id": "72bb48c9-d724-458b-bd91-3ae50e9afe0f",
"prevId": "68c71185-6e91-4b8d-8f91-795457e75ab2",
"version": "7",
"dialect": "postgresql",
@@ -1961,6 +1961,12 @@
"primaryKey": false,
"notNull": false
},
"libsqlId": {
"name": "libsqlId",
"type": "text",
"primaryKey": false,
"notNull": false
},
"userId": {
"name": "userId",
"type": "text",
@@ -2054,6 +2060,19 @@
"onDelete": "cascade",
"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": {
"name": "backup_userId_user_id_fk",
"tableFrom": "backup",
@@ -3624,19 +3643,6 @@
"notNull": true,
"default": false
},
"enableBottomlessReplication": {
"name": "enableBottomlessReplication",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"bottomlessReplicationDestinationId": {
"name": "bottomlessReplicationDestinationId",
"type": "text",
"primaryKey": false,
"notNull": false
},
"dockerImage": {
"name": "dockerImage",
"type": "text",
@@ -3781,19 +3787,6 @@
},
"indexes": {},
"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": {
"name": "libsql_environmentId_environment_environmentId_fk",
"tableFrom": "libsql",
@@ -4369,6 +4362,14 @@
"primaryKey": false,
"notNull": false
},
"serviceType": {
"name": "serviceType",
"type": "serviceType",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'application'"
},
"mountPath": {
"name": "mountPath",
"type": "text",
@@ -7562,6 +7563,14 @@
"primaryKey": false,
"notNull": true
},
"serviceType": {
"name": "serviceType",
"type": "serviceType",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'application'"
},
"appName": {
"name": "appName",
"type": "text",
@@ -7950,7 +7959,8 @@
"mariadb",
"mysql",
"mongo",
"web-server"
"web-server",
"libsql"
]
},
"public.composeType": {
@@ -8011,6 +8021,20 @@
"file"
]
},
"public.serviceType": {
"name": "serviceType",
"schema": "public",
"values": [
"application",
"postgres",
"mysql",
"mariadb",
"mongo",
"redis",
"compose",
"libsql"
]
},
"public.notificationType": {
"name": "notificationType",
"schema": "public",

File diff suppressed because it is too large Load Diff

View File

@@ -1076,15 +1076,8 @@
{
"idx": 153,
"version": "7",
"when": 1773940853496,
"tag": "0153_even_morlocks",
"breakpoints": true
},
{
"idx": 154,
"version": "7",
"when": 1773942481550,
"tag": "0154_tan_living_mummy",
"when": 1774303955927,
"tag": "0153_green_boomerang",
"breakpoints": true
}
]

View File

@@ -3,6 +3,7 @@ import {
deleteMount,
findApplicationById,
findComposeById,
findLibsqlById,
findMariadbById,
findMongoById,
findMountById,
@@ -13,7 +14,7 @@ import {
getServiceContainer,
updateMount,
} from "@dokploy/server";
import type { ServiceType } from "@dokploy/server/services/mount";
import type { ServiceType } from "@dokploy/server/db/schema/mount";
import {
checkServiceAccess,
checkServicePermissionAndAccess,
@@ -63,6 +64,10 @@ async function getServiceOrganizationId(
const compose = await findComposeById(serviceId);
return compose?.environment?.project?.organizationId ?? null;
}
case "libsql": {
const libsql = await findLibsqlById(serviceId);
return libsql?.environment?.project?.organizationId ?? null;
}
default:
return null;
}
@@ -169,7 +174,6 @@ export const mountRouter = createTRPCRouter({
listByServiceId: protectedProcedure
.input(apiFindMountByApplicationId)
.query(async ({ input, ctx }) => {
console.log("input", input);
await checkServiceAccess(ctx, input.serviceId, "read");
const organizationId = await getServiceOrganizationId(
input.serviceId,