feat(libsql): introduce libsql table schema and update related constraints

- Created a new SQL file defining the 'libsql' table with various fields including 'libsqlId', 'name', and 'databaseUser'.
- Added foreign key constraints linking 'libsql' to 'mount', 'volume_backup', 'environment', and 'server' tables.
- Updated the 'mount' and 'volume_backup' tables to include a new 'libsqlId' column and removed the obsolete 'serviceType' column.
- Added journal entry for the new schema version.
This commit is contained in:
Mauricio Siu
2026-03-19 11:21:07 -06:00
parent 9cc8231188
commit a03ec76b6f
3 changed files with 8200 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
CREATE TYPE "public"."sqldNode" AS ENUM('primary', 'replica');--> statement-breakpoint
CREATE TABLE "libsql" (
"libsqlId" text PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"appName" text NOT NULL,
"description" text,
"databaseUser" text NOT NULL,
"databasePassword" text NOT NULL,
"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,
"memoryReservation" text,
"memoryLimit" text,
"cpuReservation" text,
"cpuLimit" text,
"externalPort" integer,
"externalGRPCPort" integer,
"externalAdminPort" integer,
"applicationStatus" "applicationStatus" DEFAULT 'idle' NOT NULL,
"healthCheckSwarm" json,
"restartPolicySwarm" json,
"placementSwarm" json,
"updateConfigSwarm" json,
"rollbackConfigSwarm" json,
"modeSwarm" json,
"labelsSwarm" json,
"networkSwarm" json,
"replicas" integer DEFAULT 1 NOT NULL,
"createdAt" text NOT NULL,
"environmentId" text NOT NULL,
"serverId" text,
CONSTRAINT "libsql_appName_unique" UNIQUE("appName")
);
--> 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 "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";

File diff suppressed because it is too large Load Diff

View File

@@ -1072,6 +1072,13 @@
"when": 1773903778014,
"tag": "0152_odd_firelord",
"breakpoints": true
},
{
"idx": 153,
"version": "7",
"when": 1773940853496,
"tag": "0153_even_morlocks",
"breakpoints": true
}
]
}