Add libsql schema with new table and constraints; remove serviceType references

This commit is contained in:
Mauricio Siu
2025-09-21 02:58:53 -06:00
parent 2dffdffaf3
commit 02f0b0b1a4
5 changed files with 6 additions and 71 deletions
@@ -44,9 +44,6 @@ ALTER TABLE "libsql" ADD CONSTRAINT "libsql_environmentId_environment_environmen
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 "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;--> statement-breakpoint
ALTER TABLE "public"."mount" ALTER COLUMN "serviceType" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "mount" DROP COLUMN "serviceType";--> statement-breakpoint
ALTER TABLE "public"."volume_backup" ALTER COLUMN "serviceType" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "volume_backup" DROP COLUMN "serviceType";--> statement-breakpoint
DROP TYPE "public"."serviceType";--> statement-breakpoint DROP TYPE "public"."serviceType";
CREATE TYPE "public"."serviceType" AS ENUM('application', 'compose', 'libsql', 'mariadb', 'mongo', 'mysql', 'postgres', 'redis');--> statement-breakpoint
ALTER TABLE "public"."mount" ALTER COLUMN "serviceType" SET DATA TYPE "public"."serviceType" USING "serviceType"::"public"."serviceType";--> statement-breakpoint
ALTER TABLE "public"."volume_backup" ALTER COLUMN "serviceType" SET DATA TYPE "public"."serviceType" USING "serviceType"::"public"."serviceType";
+1 -31
View File
@@ -1,5 +1,5 @@
{ {
"id": "8537f903-ea37-4026-954c-b00299c81e55", "id": "2fbaedf4-c48c-44ba-9abd-0f9774e53bfe",
"prevId": "9f9b4142-e739-4c21-8618-676d62e9b5ae", "prevId": "9f9b4142-e739-4c21-8618-676d62e9b5ae",
"version": "7", "version": "7",
"dialect": "postgresql", "dialect": "postgresql",
@@ -3875,14 +3875,6 @@
"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",
@@ -6418,14 +6410,6 @@
"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",
@@ -6753,20 +6737,6 @@
"file" "file"
] ]
}, },
"public.serviceType": {
"name": "serviceType",
"schema": "public",
"values": [
"application",
"compose",
"libsql",
"mariadb",
"mongo",
"mysql",
"postgres",
"redis"
]
},
"public.notificationType": { "public.notificationType": {
"name": "notificationType", "name": "notificationType",
"schema": "public", "schema": "public",
+2 -2
View File
@@ -782,8 +782,8 @@
{ {
"idx": 111, "idx": 111,
"version": "7", "version": "7",
"when": 1758444932078, "when": 1758445112312,
"tag": "0111_public_fixer", "tag": "0111_tiny_landau",
"breakpoints": true "breakpoints": true
} }
] ]
-30
View File
@@ -12,17 +12,6 @@ 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",
"compose",
"libsql",
"mariadb",
"mongo",
"mysql",
"postgres",
"redis",
]);
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", {
@@ -35,7 +24,6 @@ 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,
@@ -108,24 +96,8 @@ 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",
"compose",
"libsql",
"mariadb",
"mongo",
"mysql",
"postgres",
"redis",
])
.default("application"),
}); });
export type ServiceType = NonNullable<
z.infer<typeof createSchema>["serviceType"]
>;
export const apiCreateMount = createSchema export const apiCreateMount = createSchema
.pick({ .pick({
type: true, type: true,
@@ -133,7 +105,6 @@ export const apiCreateMount = createSchema
volumeName: true, volumeName: true,
content: true, content: true,
mountPath: true, mountPath: true,
serviceType: true,
filePath: true, filePath: true,
}) })
.extend({ .extend({
@@ -161,7 +132,6 @@ export const apiFindMountByApplicationId = createSchema
}) })
.pick({ .pick({
serviceId: true, serviceId: true,
serviceType: true,
}) })
.required(); .required();
@@ -10,7 +10,6 @@ import { destinations } from "./destination";
import { libsql } from "./libsql"; import { libsql } from "./libsql";
import { mariadb } from "./mariadb"; import { mariadb } from "./mariadb";
import { mongo } from "./mongo"; import { mongo } from "./mongo";
import { serviceType } from "./mount";
import { mysql } from "./mysql"; import { mysql } from "./mysql";
import { postgres } from "./postgres"; import { postgres } from "./postgres";
import { redis } from "./redis"; import { redis } from "./redis";
@@ -24,7 +23,6 @@ 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")),