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

View File

@@ -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 "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 "public"."mount" ALTER COLUMN "serviceType" SET DATA TYPE text;--> statement-breakpoint
ALTER TABLE "public"."volume_backup" ALTER COLUMN "serviceType" SET DATA TYPE text;--> statement-breakpoint
DROP TYPE "public"."serviceType";--> statement-breakpoint
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";
ALTER TABLE "mount" DROP COLUMN "serviceType";--> statement-breakpoint
ALTER TABLE "volume_backup" DROP COLUMN "serviceType";--> statement-breakpoint
DROP TYPE "public"."serviceType";

View File

@@ -1,5 +1,5 @@
{
"id": "8537f903-ea37-4026-954c-b00299c81e55",
"id": "2fbaedf4-c48c-44ba-9abd-0f9774e53bfe",
"prevId": "9f9b4142-e739-4c21-8618-676d62e9b5ae",
"version": "7",
"dialect": "postgresql",
@@ -3875,14 +3875,6 @@
"primaryKey": false,
"notNull": false
},
"serviceType": {
"name": "serviceType",
"type": "serviceType",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'application'"
},
"mountPath": {
"name": "mountPath",
"type": "text",
@@ -6418,14 +6410,6 @@
"primaryKey": false,
"notNull": true
},
"serviceType": {
"name": "serviceType",
"type": "serviceType",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'application'"
},
"appName": {
"name": "appName",
"type": "text",
@@ -6753,20 +6737,6 @@
"file"
]
},
"public.serviceType": {
"name": "serviceType",
"schema": "public",
"values": [
"application",
"compose",
"libsql",
"mariadb",
"mongo",
"mysql",
"postgres",
"redis"
]
},
"public.notificationType": {
"name": "notificationType",
"schema": "public",

View File

@@ -782,8 +782,8 @@
{
"idx": 111,
"version": "7",
"when": 1758444932078,
"tag": "0111_public_fixer",
"when": 1758445112312,
"tag": "0111_tiny_landau",
"breakpoints": true
}
]

View File

@@ -12,17 +12,6 @@ import { mysql } from "./mysql";
import { postgres } from "./postgres";
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 mounts = pgTable("mount", {
@@ -35,7 +24,6 @@ export const mounts = pgTable("mount", {
volumeName: text("volumeName"),
filePath: text("filePath"),
content: text("content"),
serviceType: serviceType("serviceType").notNull().default("application"),
mountPath: text("mountPath").notNull(),
applicationId: text("applicationId").references(
() => applications.applicationId,
@@ -108,24 +96,8 @@ const createSchema = createInsertSchema(mounts, {
mountPath: z.string().min(1),
mountId: 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
.pick({
type: true,
@@ -133,7 +105,6 @@ export const apiCreateMount = createSchema
volumeName: true,
content: true,
mountPath: true,
serviceType: true,
filePath: true,
})
.extend({
@@ -161,7 +132,6 @@ export const apiFindMountByApplicationId = createSchema
})
.pick({
serviceId: true,
serviceType: true,
})
.required();

View File

@@ -10,7 +10,6 @@ import { destinations } from "./destination";
import { libsql } from "./libsql";
import { mariadb } from "./mariadb";
import { mongo } from "./mongo";
import { serviceType } from "./mount";
import { mysql } from "./mysql";
import { postgres } from "./postgres";
import { redis } from "./redis";
@@ -24,7 +23,6 @@ export const volumeBackups = pgTable("volume_backup", {
name: text("name").notNull(),
volumeName: text("volumeName").notNull(),
prefix: text("prefix").notNull(),
serviceType: serviceType("serviceType").notNull().default("application"),
appName: text("appName")
.notNull()
.$defaultFn(() => generateAppName("volumeBackup")),