Skip to content

Commit 6ff2ca0

Browse files
fix: scope dokploy-server schedules to organization instead of user (Dokploy#4526)
* fix: scope dokploy-server schedules to organization instead of user Replaces userId with organizationId on the schedule table so that global (dokploy-server) schedules are shared across all owners and admins of the same organization, while remaining isolated between different organizations. Includes a data migration that backfills organizationId from the owner membership record for any existing dokploy-server schedules. Closes Dokploy#4300 * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent d56a17c commit 6ff2ca0

7 files changed

Lines changed: 8381 additions & 66 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ALTER TABLE "schedule" DROP CONSTRAINT "schedule_userId_user_id_fk";
2+
--> statement-breakpoint
3+
ALTER TABLE "schedule" ADD COLUMN "organizationId" text;--> statement-breakpoint
4+
ALTER TABLE "schedule" ADD CONSTRAINT "schedule_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
5+
UPDATE "schedule" s
6+
SET "organizationId" = m."organization_id"
7+
FROM "member" m
8+
WHERE s."scheduleType" = 'dokploy-server'
9+
AND s."userId" = m."user_id"
10+
AND m."role" = 'owner';--> statement-breakpoint
11+
ALTER TABLE "schedule" DROP COLUMN "userId";

0 commit comments

Comments
 (0)