mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: update organization
This commit is contained in:
@@ -1,2 +0,0 @@
|
|||||||
ALTER TABLE "project" ADD COLUMN "organizationId" text;--> statement-breakpoint
|
|
||||||
ALTER TABLE "project" ADD CONSTRAINT "project_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
16
apps/dokploy/drizzle/0070_nervous_vivisector.sql
Normal file
16
apps/dokploy/drizzle/0070_nervous_vivisector.sql
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
ALTER TABLE "project" ADD COLUMN "organizationId" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "destination" ADD COLUMN "organizationId" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "certificate" ADD COLUMN "organizationId" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "registry" ADD COLUMN "organizationId" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "notification" ADD COLUMN "organizationId" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "ssh-key" ADD COLUMN "organizationId" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "git_provider" ADD COLUMN "organizationId" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "server" ADD COLUMN "organizationId" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "project" ADD CONSTRAINT "project_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "destination" ADD CONSTRAINT "destination_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "certificate" ADD CONSTRAINT "certificate_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "registry" ADD CONSTRAINT "registry_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "notification" ADD CONSTRAINT "notification_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "ssh-key" ADD CONSTRAINT "ssh-key_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "git_provider" ADD CONSTRAINT "git_provider_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "server" ADD CONSTRAINT "server_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
-- Custom SQL migration file, put your code below! --
|
-- Custom SQL migration file
|
||||||
-- Primero, actualizamos los proyectos con la organización del usuario
|
|
||||||
|
-- Actualizar projects
|
||||||
UPDATE "project" p
|
UPDATE "project" p
|
||||||
SET "organizationId" = (
|
SET "organizationId" = (
|
||||||
SELECT m."organization_id"
|
SELECT m."organization_id"
|
||||||
@@ -10,18 +11,132 @@ SET "organizationId" = (
|
|||||||
)
|
)
|
||||||
WHERE p."organizationId" IS NULL;
|
WHERE p."organizationId" IS NULL;
|
||||||
|
|
||||||
-- Verificamos que todos los proyectos tengan una organización
|
-- Actualizar servers
|
||||||
|
UPDATE "server" s
|
||||||
|
SET "organizationId" = (
|
||||||
|
SELECT m."organization_id"
|
||||||
|
FROM "member" m
|
||||||
|
WHERE m."user_id" = s."userId"
|
||||||
|
AND m."role" = 'owner'
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
|
WHERE s."organizationId" IS NULL;
|
||||||
|
|
||||||
|
-- Actualizar ssh-keys
|
||||||
|
UPDATE "ssh-key" k
|
||||||
|
SET "organizationId" = (
|
||||||
|
SELECT m."organization_id"
|
||||||
|
FROM "member" m
|
||||||
|
WHERE m."user_id" = k."userId"
|
||||||
|
AND m."role" = 'owner'
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
|
WHERE k."organizationId" IS NULL;
|
||||||
|
|
||||||
|
-- Actualizar destinations
|
||||||
|
UPDATE "destination" d
|
||||||
|
SET "organizationId" = (
|
||||||
|
SELECT m."organization_id"
|
||||||
|
FROM "member" m
|
||||||
|
WHERE m."user_id" = d."userId"
|
||||||
|
AND m."role" = 'owner'
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
|
WHERE d."organizationId" IS NULL;
|
||||||
|
|
||||||
|
-- Actualizar registry
|
||||||
|
UPDATE "registry" r
|
||||||
|
SET "organizationId" = (
|
||||||
|
SELECT m."organization_id"
|
||||||
|
FROM "member" m
|
||||||
|
WHERE m."user_id" = r."userId"
|
||||||
|
AND m."role" = 'owner'
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
|
WHERE r."organizationId" IS NULL;
|
||||||
|
|
||||||
|
-- Actualizar notifications
|
||||||
|
UPDATE "notification" n
|
||||||
|
SET "organizationId" = (
|
||||||
|
SELECT m."organization_id"
|
||||||
|
FROM "member" m
|
||||||
|
WHERE m."user_id" = n."userId"
|
||||||
|
AND m."role" = 'owner'
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
|
WHERE n."organizationId" IS NULL;
|
||||||
|
|
||||||
|
-- Actualizar certificates
|
||||||
|
UPDATE "certificate" c
|
||||||
|
SET "organizationId" = (
|
||||||
|
SELECT m."organization_id"
|
||||||
|
FROM "member" m
|
||||||
|
WHERE m."user_id" = c."userId"
|
||||||
|
AND m."role" = 'owner'
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
|
WHERE c."organizationId" IS NULL;
|
||||||
|
|
||||||
|
-- Actualizar git_provider
|
||||||
|
UPDATE "git_provider" g
|
||||||
|
SET "organizationId" = (
|
||||||
|
SELECT m."organization_id"
|
||||||
|
FROM "member" m
|
||||||
|
WHERE m."user_id" = g."userId"
|
||||||
|
AND m."role" = 'owner'
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
|
WHERE g."organizationId" IS NULL;
|
||||||
|
|
||||||
|
-- Verificar que todos los recursos tengan una organización
|
||||||
DO $$
|
DO $$
|
||||||
BEGIN
|
BEGIN
|
||||||
IF EXISTS (
|
IF EXISTS (
|
||||||
SELECT 1
|
SELECT 1 FROM "project" WHERE "organizationId" IS NULL
|
||||||
FROM "project"
|
UNION ALL
|
||||||
WHERE "organizationId" IS NULL
|
SELECT 1 FROM "server" WHERE "organizationId" IS NULL
|
||||||
|
UNION ALL
|
||||||
|
SELECT 1 FROM "ssh-key" WHERE "organizationId" IS NULL
|
||||||
|
UNION ALL
|
||||||
|
SELECT 1 FROM "destination" WHERE "organizationId" IS NULL
|
||||||
|
UNION ALL
|
||||||
|
SELECT 1 FROM "registry" WHERE "organizationId" IS NULL
|
||||||
|
UNION ALL
|
||||||
|
SELECT 1 FROM "notification" WHERE "organizationId" IS NULL
|
||||||
|
UNION ALL
|
||||||
|
SELECT 1 FROM "certificate" WHERE "organizationId" IS NULL
|
||||||
|
UNION ALL
|
||||||
|
SELECT 1 FROM "git_provider" WHERE "organizationId" IS NULL
|
||||||
) THEN
|
) THEN
|
||||||
RAISE EXCEPTION 'Hay proyectos sin organización asignada';
|
RAISE EXCEPTION 'Hay recursos sin organización asignada';
|
||||||
END IF;
|
END IF;
|
||||||
END $$;
|
END $$;
|
||||||
|
|
||||||
-- Hacemos organization_id NOT NULL después de la migración
|
-- Hacer organization_id NOT NULL en todas las tablas
|
||||||
ALTER TABLE "project"
|
ALTER TABLE "project" ALTER COLUMN "organizationId" SET NOT NULL;
|
||||||
ALTER COLUMN "organizationId" SET NOT NULL;
|
ALTER TABLE "server" ALTER COLUMN "organizationId" SET NOT NULL;
|
||||||
|
ALTER TABLE "ssh-key" ALTER COLUMN "organizationId" SET NOT NULL;
|
||||||
|
ALTER TABLE "destination" ALTER COLUMN "organizationId" SET NOT NULL;
|
||||||
|
ALTER TABLE "registry" ALTER COLUMN "organizationId" SET NOT NULL;
|
||||||
|
ALTER TABLE "notification" ALTER COLUMN "organizationId" SET NOT NULL;
|
||||||
|
ALTER TABLE "certificate" ALTER COLUMN "organizationId" SET NOT NULL;
|
||||||
|
ALTER TABLE "git_provider" ALTER COLUMN "organizationId" SET NOT NULL;
|
||||||
|
|
||||||
|
-- Crear índices para mejorar el rendimiento de búsquedas por organización
|
||||||
|
CREATE INDEX IF NOT EXISTS "idx_project_organization" ON "project" ("organizationId");
|
||||||
|
CREATE INDEX IF NOT EXISTS "idx_server_organization" ON "server" ("organizationId");
|
||||||
|
CREATE INDEX IF NOT EXISTS "idx_sshkey_organization" ON "ssh-key" ("organizationId");
|
||||||
|
CREATE INDEX IF NOT EXISTS "idx_destination_organization" ON "destination" ("organizationId");
|
||||||
|
CREATE INDEX IF NOT EXISTS "idx_registry_organization" ON "registry" ("organizationId");
|
||||||
|
CREATE INDEX IF NOT EXISTS "idx_notification_organization" ON "notification" ("organizationId");
|
||||||
|
CREATE INDEX IF NOT EXISTS "idx_certificate_organization" ON "certificate" ("organizationId");
|
||||||
|
CREATE INDEX IF NOT EXISTS "idx_git_provider_organization" ON "git_provider" ("organizationId");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
32
apps/dokploy/drizzle/0072_lazy_pixie.sql
Normal file
32
apps/dokploy/drizzle/0072_lazy_pixie.sql
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
ALTER TABLE "project" DROP CONSTRAINT "project_userId_user_temp_id_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "destination" DROP CONSTRAINT "destination_userId_user_temp_id_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "certificate" DROP CONSTRAINT "certificate_userId_user_temp_id_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "registry" DROP CONSTRAINT "registry_userId_user_temp_id_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "notification" DROP CONSTRAINT "notification_userId_user_temp_id_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "ssh-key" DROP CONSTRAINT "ssh-key_userId_user_temp_id_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "git_provider" DROP CONSTRAINT "git_provider_userId_user_temp_id_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "server" DROP CONSTRAINT "server_userId_user_temp_id_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "project" ALTER COLUMN "organizationId" SET NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "destination" ALTER COLUMN "organizationId" SET NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "certificate" ALTER COLUMN "organizationId" SET NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "registry" ALTER COLUMN "organizationId" SET NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "notification" ALTER COLUMN "organizationId" SET NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "ssh-key" ALTER COLUMN "organizationId" SET NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "git_provider" ALTER COLUMN "organizationId" SET NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "server" ALTER COLUMN "organizationId" SET NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "project" DROP COLUMN "userId";--> statement-breakpoint
|
||||||
|
ALTER TABLE "destination" DROP COLUMN "userId";--> statement-breakpoint
|
||||||
|
ALTER TABLE "certificate" DROP COLUMN "userId";--> statement-breakpoint
|
||||||
|
ALTER TABLE "registry" DROP COLUMN "userId";--> statement-breakpoint
|
||||||
|
ALTER TABLE "notification" DROP COLUMN "userId";--> statement-breakpoint
|
||||||
|
ALTER TABLE "ssh-key" DROP COLUMN "userId";--> statement-breakpoint
|
||||||
|
ALTER TABLE "git_provider" DROP COLUMN "userId";--> statement-breakpoint
|
||||||
|
ALTER TABLE "server" DROP COLUMN "userId";
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"id": "cd06dbbf-61cb-4aba-b096-49a1850ff32b",
|
"id": "8e8626de-fb34-4c11-b9d0-b7a958993fb7",
|
||||||
"prevId": "e0842a94-530d-4a3c-a6b1-16cf37618b8b",
|
"prevId": "e0842a94-530d-4a3c-a6b1-16cf37618b8b",
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"dialect": "postgresql",
|
"dialect": "postgresql",
|
||||||
@@ -2352,6 +2352,12 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"indexes": {},
|
||||||
@@ -2368,6 +2374,19 @@
|
|||||||
],
|
],
|
||||||
"onDelete": "cascade",
|
"onDelete": "cascade",
|
||||||
"onUpdate": "no action"
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"destination_organizationId_organization_id_fk": {
|
||||||
|
"name": "destination_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "destination",
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -2761,6 +2780,12 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
"serverId": {
|
"serverId": {
|
||||||
"name": "serverId",
|
"name": "serverId",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -2783,6 +2808,19 @@
|
|||||||
"onDelete": "cascade",
|
"onDelete": "cascade",
|
||||||
"onUpdate": "no action"
|
"onUpdate": "no action"
|
||||||
},
|
},
|
||||||
|
"certificate_organizationId_organization_id_fk": {
|
||||||
|
"name": "certificate_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "certificate",
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
"certificate_serverId_server_serverId_fk": {
|
"certificate_serverId_server_serverId_fk": {
|
||||||
"name": "certificate_serverId_server_serverId_fk",
|
"name": "certificate_serverId_server_serverId_fk",
|
||||||
"tableFrom": "certificate",
|
"tableFrom": "certificate",
|
||||||
@@ -3677,6 +3715,12 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"indexes": {},
|
||||||
@@ -3693,6 +3737,19 @@
|
|||||||
],
|
],
|
||||||
"onDelete": "cascade",
|
"onDelete": "cascade",
|
||||||
"onUpdate": "no action"
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"registry_organizationId_organization_id_fk": {
|
||||||
|
"name": "registry_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "registry",
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -3937,6 +3994,12 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"indexes": {},
|
||||||
@@ -4018,6 +4081,19 @@
|
|||||||
],
|
],
|
||||||
"onDelete": "cascade",
|
"onDelete": "cascade",
|
||||||
"onUpdate": "no action"
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"notification_organizationId_organization_id_fk": {
|
||||||
|
"name": "notification_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "notification",
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -4140,6 +4216,12 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"indexes": {},
|
||||||
@@ -4156,6 +4238,19 @@
|
|||||||
],
|
],
|
||||||
"onDelete": "cascade",
|
"onDelete": "cascade",
|
||||||
"onUpdate": "no action"
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"ssh-key_organizationId_organization_id_fk": {
|
||||||
|
"name": "ssh-key_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "ssh-key",
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -4199,6 +4294,12 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"indexes": {},
|
||||||
@@ -4215,6 +4316,19 @@
|
|||||||
],
|
],
|
||||||
"onDelete": "cascade",
|
"onDelete": "cascade",
|
||||||
"onUpdate": "no action"
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"git_provider_organizationId_organization_id_fk": {
|
||||||
|
"name": "git_provider_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "git_provider",
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -4515,6 +4629,12 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
"serverStatus": {
|
"serverStatus": {
|
||||||
"name": "serverStatus",
|
"name": "serverStatus",
|
||||||
"type": "serverStatus",
|
"type": "serverStatus",
|
||||||
@@ -4559,6 +4679,19 @@
|
|||||||
"onDelete": "cascade",
|
"onDelete": "cascade",
|
||||||
"onUpdate": "no action"
|
"onUpdate": "no action"
|
||||||
},
|
},
|
||||||
|
"server_organizationId_organization_id_fk": {
|
||||||
|
"name": "server_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "server",
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
"server_sshKeyId_ssh-key_sshKeyId_fk": {
|
"server_sshKeyId_ssh-key_sshKeyId_fk": {
|
||||||
"name": "server_sshKeyId_ssh-key_sshKeyId_fk",
|
"name": "server_sshKeyId_ssh-key_sshKeyId_fk",
|
||||||
"tableFrom": "server",
|
"tableFrom": "server",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"id": "30a4b462-2f38-42ae-8291-f6a2ce6d0bb4",
|
"id": "11cb27c0-0f5a-4ec9-98be-5b6f7c5e7799",
|
||||||
"prevId": "cd06dbbf-61cb-4aba-b096-49a1850ff32b",
|
"prevId": "8e8626de-fb34-4c11-b9d0-b7a958993fb7",
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"dialect": "postgresql",
|
"dialect": "postgresql",
|
||||||
"tables": {
|
"tables": {
|
||||||
@@ -2352,6 +2352,12 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"indexes": {},
|
||||||
@@ -2368,6 +2374,19 @@
|
|||||||
],
|
],
|
||||||
"onUpdate": "no action",
|
"onUpdate": "no action",
|
||||||
"onDelete": "cascade"
|
"onDelete": "cascade"
|
||||||
|
},
|
||||||
|
"destination_organizationId_organization_id_fk": {
|
||||||
|
"name": "destination_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "destination",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onUpdate": "no action",
|
||||||
|
"onDelete": "cascade"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -2761,6 +2780,12 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
"serverId": {
|
"serverId": {
|
||||||
"name": "serverId",
|
"name": "serverId",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -2783,6 +2808,19 @@
|
|||||||
"onUpdate": "no action",
|
"onUpdate": "no action",
|
||||||
"onDelete": "cascade"
|
"onDelete": "cascade"
|
||||||
},
|
},
|
||||||
|
"certificate_organizationId_organization_id_fk": {
|
||||||
|
"name": "certificate_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "certificate",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onUpdate": "no action",
|
||||||
|
"onDelete": "cascade"
|
||||||
|
},
|
||||||
"certificate_serverId_server_serverId_fk": {
|
"certificate_serverId_server_serverId_fk": {
|
||||||
"name": "certificate_serverId_server_serverId_fk",
|
"name": "certificate_serverId_server_serverId_fk",
|
||||||
"tableFrom": "certificate",
|
"tableFrom": "certificate",
|
||||||
@@ -3677,6 +3715,12 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"indexes": {},
|
||||||
@@ -3693,6 +3737,19 @@
|
|||||||
],
|
],
|
||||||
"onUpdate": "no action",
|
"onUpdate": "no action",
|
||||||
"onDelete": "cascade"
|
"onDelete": "cascade"
|
||||||
|
},
|
||||||
|
"registry_organizationId_organization_id_fk": {
|
||||||
|
"name": "registry_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "registry",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onUpdate": "no action",
|
||||||
|
"onDelete": "cascade"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -3937,6 +3994,12 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"indexes": {},
|
||||||
@@ -4018,6 +4081,19 @@
|
|||||||
],
|
],
|
||||||
"onUpdate": "no action",
|
"onUpdate": "no action",
|
||||||
"onDelete": "cascade"
|
"onDelete": "cascade"
|
||||||
|
},
|
||||||
|
"notification_organizationId_organization_id_fk": {
|
||||||
|
"name": "notification_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "notification",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onUpdate": "no action",
|
||||||
|
"onDelete": "cascade"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -4140,6 +4216,12 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"indexes": {},
|
||||||
@@ -4156,6 +4238,19 @@
|
|||||||
],
|
],
|
||||||
"onUpdate": "no action",
|
"onUpdate": "no action",
|
||||||
"onDelete": "cascade"
|
"onDelete": "cascade"
|
||||||
|
},
|
||||||
|
"ssh-key_organizationId_organization_id_fk": {
|
||||||
|
"name": "ssh-key_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "ssh-key",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onUpdate": "no action",
|
||||||
|
"onDelete": "cascade"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -4199,6 +4294,12 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"indexes": {},
|
||||||
@@ -4215,6 +4316,19 @@
|
|||||||
],
|
],
|
||||||
"onUpdate": "no action",
|
"onUpdate": "no action",
|
||||||
"onDelete": "cascade"
|
"onDelete": "cascade"
|
||||||
|
},
|
||||||
|
"git_provider_organizationId_organization_id_fk": {
|
||||||
|
"name": "git_provider_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "git_provider",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onUpdate": "no action",
|
||||||
|
"onDelete": "cascade"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -4515,6 +4629,12 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
"organizationId": {
|
||||||
|
"name": "organizationId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
"serverStatus": {
|
"serverStatus": {
|
||||||
"name": "serverStatus",
|
"name": "serverStatus",
|
||||||
"type": "serverStatus",
|
"type": "serverStatus",
|
||||||
@@ -4559,6 +4679,19 @@
|
|||||||
"onUpdate": "no action",
|
"onUpdate": "no action",
|
||||||
"onDelete": "cascade"
|
"onDelete": "cascade"
|
||||||
},
|
},
|
||||||
|
"server_organizationId_organization_id_fk": {
|
||||||
|
"name": "server_organizationId_organization_id_fk",
|
||||||
|
"tableFrom": "server",
|
||||||
|
"columnsFrom": [
|
||||||
|
"organizationId"
|
||||||
|
],
|
||||||
|
"tableTo": "organization",
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onUpdate": "no action",
|
||||||
|
"onDelete": "cascade"
|
||||||
|
},
|
||||||
"server_sshKeyId_ssh-key_sshKeyId_fk": {
|
"server_sshKeyId_ssh-key_sshKeyId_fk": {
|
||||||
"name": "server_sshKeyId_ssh-key_sshKeyId_fk",
|
"name": "server_sshKeyId_ssh-key_sshKeyId_fk",
|
||||||
"tableFrom": "server",
|
"tableFrom": "server",
|
||||||
|
|||||||
5280
apps/dokploy/drizzle/meta/0072_snapshot.json
Normal file
5280
apps/dokploy/drizzle/meta/0072_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -495,16 +495,23 @@
|
|||||||
{
|
{
|
||||||
"idx": 70,
|
"idx": 70,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1739671371444,
|
"when": 1739671869809,
|
||||||
"tag": "0070_dusty_wind_dancer",
|
"tag": "0070_nervous_vivisector",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idx": 71,
|
"idx": 71,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1739671387634,
|
"when": 1739671878698,
|
||||||
"tag": "0071_migrate-data-projects",
|
"tag": "0071_migrate-data-projects",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 72,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1739672367223,
|
||||||
|
"tag": "0072_lazy_pixie",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import { server } from "./server";
|
|||||||
import { users_temp } from "./user";
|
import { users_temp } from "./user";
|
||||||
// import { user } from "./user";
|
// import { user } from "./user";
|
||||||
import { generateAppName } from "./utils";
|
import { generateAppName } from "./utils";
|
||||||
|
import { organization } from "./account";
|
||||||
|
|
||||||
export const certificates = pgTable("certificate", {
|
export const certificates = pgTable("certificate", {
|
||||||
certificateId: text("certificateId")
|
certificateId: text("certificateId")
|
||||||
@@ -22,12 +23,9 @@ export const certificates = pgTable("certificate", {
|
|||||||
.$defaultFn(() => generateAppName("certificate"))
|
.$defaultFn(() => generateAppName("certificate"))
|
||||||
.unique(),
|
.unique(),
|
||||||
autoRenew: boolean("autoRenew"),
|
autoRenew: boolean("autoRenew"),
|
||||||
// userId: text("userId").references(() => user.userId, {
|
organizationId: text("organizationId")
|
||||||
// onDelete: "cascade",
|
|
||||||
// }),
|
|
||||||
userId: text("userId")
|
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
.references(() => organization.id, { onDelete: "cascade" }),
|
||||||
serverId: text("serverId").references(() => server.serverId, {
|
serverId: text("serverId").references(() => server.serverId, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
}),
|
}),
|
||||||
@@ -40,9 +38,9 @@ export const certificatesRelations = relations(
|
|||||||
fields: [certificates.serverId],
|
fields: [certificates.serverId],
|
||||||
references: [server.serverId],
|
references: [server.serverId],
|
||||||
}),
|
}),
|
||||||
user: one(users_temp, {
|
organization: one(organization, {
|
||||||
fields: [certificates.userId],
|
fields: [certificates.organizationId],
|
||||||
references: [users_temp.id],
|
references: [organization.id],
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { z } from "zod";
|
|||||||
import { admins } from "./admin";
|
import { admins } from "./admin";
|
||||||
import { backups } from "./backups";
|
import { backups } from "./backups";
|
||||||
import { users_temp } from "./user";
|
import { users_temp } from "./user";
|
||||||
|
import { organization } from "./account";
|
||||||
// import { user } from "./user";
|
// import { user } from "./user";
|
||||||
|
|
||||||
export const destinations = pgTable("destination", {
|
export const destinations = pgTable("destination", {
|
||||||
@@ -21,18 +22,19 @@ export const destinations = pgTable("destination", {
|
|||||||
region: text("region").notNull(),
|
region: text("region").notNull(),
|
||||||
// maybe it can be null
|
// maybe it can be null
|
||||||
endpoint: text("endpoint").notNull(),
|
endpoint: text("endpoint").notNull(),
|
||||||
// userId: text("userId")
|
organizationId: text("organizationId")
|
||||||
// .notNull()
|
|
||||||
// .references(() => user.userId, { onDelete: "cascade" }),
|
|
||||||
userId: text("userId")
|
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
.references(() => organization.id, { onDelete: "cascade" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const destinationsRelations = relations(
|
export const destinationsRelations = relations(
|
||||||
destinations,
|
destinations,
|
||||||
({ many, one }) => ({
|
({ many, one }) => ({
|
||||||
backups: many(backups),
|
backups: many(backups),
|
||||||
|
organization: one(organization, {
|
||||||
|
fields: [destinations.organizationId],
|
||||||
|
references: [organization.id],
|
||||||
|
}),
|
||||||
// user: one(user, {
|
// user: one(user, {
|
||||||
// fields: [destinations.userId],
|
// fields: [destinations.userId],
|
||||||
// references: [user.id],
|
// references: [user.id],
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { bitbucket } from "./bitbucket";
|
|||||||
import { github } from "./github";
|
import { github } from "./github";
|
||||||
import { gitlab } from "./gitlab";
|
import { gitlab } from "./gitlab";
|
||||||
import { users_temp } from "./user";
|
import { users_temp } from "./user";
|
||||||
|
import { organization } from "./account";
|
||||||
// import { user } from "./user";
|
// import { user } from "./user";
|
||||||
|
|
||||||
export const gitProviderType = pgEnum("gitProviderType", [
|
export const gitProviderType = pgEnum("gitProviderType", [
|
||||||
@@ -26,12 +27,9 @@ export const gitProvider = pgTable("git_provider", {
|
|||||||
createdAt: text("createdAt")
|
createdAt: text("createdAt")
|
||||||
.notNull()
|
.notNull()
|
||||||
.$defaultFn(() => new Date().toISOString()),
|
.$defaultFn(() => new Date().toISOString()),
|
||||||
// userId: text("userId").references(() => user.userId, {
|
organizationId: text("organizationId")
|
||||||
// onDelete: "cascade",
|
|
||||||
// }),
|
|
||||||
userId: text("userId")
|
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
.references(() => organization.id, { onDelete: "cascade" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const gitProviderRelations = relations(gitProvider, ({ one, many }) => ({
|
export const gitProviderRelations = relations(gitProvider, ({ one, many }) => ({
|
||||||
@@ -47,9 +45,9 @@ export const gitProviderRelations = relations(gitProvider, ({ one, many }) => ({
|
|||||||
fields: [gitProvider.gitProviderId],
|
fields: [gitProvider.gitProviderId],
|
||||||
references: [bitbucket.gitProviderId],
|
references: [bitbucket.gitProviderId],
|
||||||
}),
|
}),
|
||||||
user: one(users_temp, {
|
organization: one(organization, {
|
||||||
fields: [gitProvider.userId],
|
fields: [gitProvider.organizationId],
|
||||||
references: [users_temp.id],
|
references: [organization.id],
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { createInsertSchema } from "drizzle-zod";
|
|||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { users_temp } from "./user";
|
import { users_temp } from "./user";
|
||||||
|
import { organization } from "./account";
|
||||||
// import { user } from "./user";
|
// import { user } from "./user";
|
||||||
|
|
||||||
export const notificationType = pgEnum("notificationType", [
|
export const notificationType = pgEnum("notificationType", [
|
||||||
@@ -45,12 +46,9 @@ export const notifications = pgTable("notification", {
|
|||||||
gotifyId: text("gotifyId").references(() => gotify.gotifyId, {
|
gotifyId: text("gotifyId").references(() => gotify.gotifyId, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
}),
|
}),
|
||||||
// userId: text("userId").references(() => user.userId, {
|
organizationId: text("organizationId")
|
||||||
// onDelete: "cascade",
|
|
||||||
// }),
|
|
||||||
userId: text("userId")
|
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
.references(() => organization.id, { onDelete: "cascade" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const slack = pgTable("slack", {
|
export const slack = pgTable("slack", {
|
||||||
@@ -125,9 +123,9 @@ export const notificationsRelations = relations(notifications, ({ one }) => ({
|
|||||||
fields: [notifications.gotifyId],
|
fields: [notifications.gotifyId],
|
||||||
references: [gotify.gotifyId],
|
references: [gotify.gotifyId],
|
||||||
}),
|
}),
|
||||||
user: one(users_temp, {
|
organization: one(organization, {
|
||||||
fields: [notifications.userId],
|
fields: [notifications.organizationId],
|
||||||
references: [users_temp.id],
|
references: [organization.id],
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -26,14 +26,9 @@ export const projects = pgTable("project", {
|
|||||||
createdAt: text("createdAt")
|
createdAt: text("createdAt")
|
||||||
.notNull()
|
.notNull()
|
||||||
.$defaultFn(() => new Date().toISOString()),
|
.$defaultFn(() => new Date().toISOString()),
|
||||||
// userId: text("userId")
|
|
||||||
// .notNull()
|
|
||||||
// .references(() => user.userId, { onDelete: "cascade" }),
|
|
||||||
userId: text("userId")
|
|
||||||
.notNull()
|
|
||||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
|
||||||
organizationId: text("organizationId")
|
organizationId: text("organizationId")
|
||||||
// .notNull()
|
.notNull()
|
||||||
.references(() => organization.id, { onDelete: "cascade" }),
|
.references(() => organization.id, { onDelete: "cascade" }),
|
||||||
env: text("env").notNull().default(""),
|
env: text("env").notNull().default(""),
|
||||||
});
|
});
|
||||||
@@ -46,14 +41,10 @@ export const projectRelations = relations(projects, ({ many, one }) => ({
|
|||||||
mongo: many(mongo),
|
mongo: many(mongo),
|
||||||
redis: many(redis),
|
redis: many(redis),
|
||||||
compose: many(compose),
|
compose: many(compose),
|
||||||
user: one(users_temp, {
|
organization: one(organization, {
|
||||||
fields: [projects.userId],
|
fields: [projects.organizationId],
|
||||||
references: [users_temp.id],
|
references: [organization.id],
|
||||||
}),
|
}),
|
||||||
// user: one(user, {
|
|
||||||
// fields: [projects.userId],
|
|
||||||
// references: [user.id],
|
|
||||||
// }),
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const createSchema = createInsertSchema(projects, {
|
const createSchema = createInsertSchema(projects, {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { z } from "zod";
|
|||||||
import { admins } from "./admin";
|
import { admins } from "./admin";
|
||||||
import { applications } from "./application";
|
import { applications } from "./application";
|
||||||
import { users_temp } from "./user";
|
import { users_temp } from "./user";
|
||||||
|
import { organization } from "./account";
|
||||||
// import { user } from "./user";
|
// import { user } from "./user";
|
||||||
/**
|
/**
|
||||||
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
|
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
|
||||||
@@ -29,12 +30,9 @@ export const registry = pgTable("registry", {
|
|||||||
.notNull()
|
.notNull()
|
||||||
.$defaultFn(() => new Date().toISOString()),
|
.$defaultFn(() => new Date().toISOString()),
|
||||||
registryType: registryType("selfHosted").notNull().default("cloud"),
|
registryType: registryType("selfHosted").notNull().default("cloud"),
|
||||||
// userId: text("userId")
|
organizationId: text("organizationId")
|
||||||
// .notNull()
|
|
||||||
// .references(() => user.userId, { onDelete: "cascade" }),
|
|
||||||
userId: text("userId")
|
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
.references(() => organization.id, { onDelete: "cascade" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const registryRelations = relations(registry, ({ one, many }) => ({
|
export const registryRelations = relations(registry, ({ one, many }) => ({
|
||||||
@@ -50,7 +48,7 @@ const createSchema = createInsertSchema(registry, {
|
|||||||
username: z.string().min(1),
|
username: z.string().min(1),
|
||||||
password: z.string().min(1),
|
password: z.string().min(1),
|
||||||
registryUrl: z.string(),
|
registryUrl: z.string(),
|
||||||
userId: z.string().min(1),
|
organizationId: z.string().min(1),
|
||||||
registryId: z.string().min(1),
|
registryId: z.string().min(1),
|
||||||
registryType: z.enum(["cloud"]),
|
registryType: z.enum(["cloud"]),
|
||||||
imagePrefix: z.string().nullable().optional(),
|
imagePrefix: z.string().nullable().optional(),
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { sshKeys } from "./ssh-key";
|
|||||||
import { users_temp } from "./user";
|
import { users_temp } from "./user";
|
||||||
// import { user } from "./user";
|
// import { user } from "./user";
|
||||||
import { generateAppName } from "./utils";
|
import { generateAppName } from "./utils";
|
||||||
|
import { organization } from "./account";
|
||||||
|
|
||||||
export const serverStatus = pgEnum("serverStatus", ["active", "inactive"]);
|
export const serverStatus = pgEnum("serverStatus", ["active", "inactive"]);
|
||||||
|
|
||||||
@@ -43,13 +44,9 @@ export const server = pgTable("server", {
|
|||||||
.$defaultFn(() => generateAppName("server")),
|
.$defaultFn(() => generateAppName("server")),
|
||||||
enableDockerCleanup: boolean("enableDockerCleanup").notNull().default(false),
|
enableDockerCleanup: boolean("enableDockerCleanup").notNull().default(false),
|
||||||
createdAt: text("createdAt").notNull(),
|
createdAt: text("createdAt").notNull(),
|
||||||
// .$defaultFn(() => new Date().toISOString()),
|
organizationId: text("organizationId")
|
||||||
// userId: text("userId")
|
|
||||||
// .notNull()
|
|
||||||
// .references(() => user.userId, { onDelete: "cascade" }),
|
|
||||||
userId: text("userId")
|
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
.references(() => organization.id, { onDelete: "cascade" }),
|
||||||
serverStatus: serverStatus("serverStatus").notNull().default("active"),
|
serverStatus: serverStatus("serverStatus").notNull().default("active"),
|
||||||
command: text("command").notNull().default(""),
|
command: text("command").notNull().default(""),
|
||||||
sshKeyId: text("sshKeyId").references(() => sshKeys.sshKeyId, {
|
sshKeyId: text("sshKeyId").references(() => sshKeys.sshKeyId, {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { applications } from "./application";
|
|||||||
import { compose } from "./compose";
|
import { compose } from "./compose";
|
||||||
import { server } from "./server";
|
import { server } from "./server";
|
||||||
import { users_temp } from "./user";
|
import { users_temp } from "./user";
|
||||||
|
import { organization } from "./account";
|
||||||
// import { user } from "./user";
|
// import { user } from "./user";
|
||||||
|
|
||||||
export const sshKeys = pgTable("ssh-key", {
|
export const sshKeys = pgTable("ssh-key", {
|
||||||
@@ -23,21 +24,18 @@ export const sshKeys = pgTable("ssh-key", {
|
|||||||
.notNull()
|
.notNull()
|
||||||
.$defaultFn(() => new Date().toISOString()),
|
.$defaultFn(() => new Date().toISOString()),
|
||||||
lastUsedAt: text("lastUsedAt"),
|
lastUsedAt: text("lastUsedAt"),
|
||||||
// userId: text("userId").references(() => user.userId, {
|
organizationId: text("organizationId")
|
||||||
// onDelete: "cascade",
|
|
||||||
// }),
|
|
||||||
userId: text("userId")
|
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
.references(() => organization.id, { onDelete: "cascade" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const sshKeysRelations = relations(sshKeys, ({ many, one }) => ({
|
export const sshKeysRelations = relations(sshKeys, ({ many, one }) => ({
|
||||||
applications: many(applications),
|
applications: many(applications),
|
||||||
compose: many(compose),
|
compose: many(compose),
|
||||||
servers: many(server),
|
servers: many(server),
|
||||||
user: one(users_temp, {
|
organization: one(organization, {
|
||||||
fields: [sshKeys.userId],
|
fields: [sshKeys.organizationId],
|
||||||
references: [users_temp.id],
|
references: [organization.id],
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -53,7 +51,7 @@ export const apiCreateSshKey = createSchema
|
|||||||
description: true,
|
description: true,
|
||||||
privateKey: true,
|
privateKey: true,
|
||||||
publicKey: true,
|
publicKey: true,
|
||||||
userId: true,
|
organizationId: true,
|
||||||
})
|
})
|
||||||
.merge(sshKeyCreate.pick({ privateKey: true }));
|
.merge(sshKeyCreate.pick({ privateKey: true }));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user