mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-23 06:45:27 +02:00
* 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 #4300 * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
12 lines
640 B
SQL
12 lines
640 B
SQL
ALTER TABLE "schedule" DROP CONSTRAINT "schedule_userId_user_id_fk";
|
|
--> statement-breakpoint
|
|
ALTER TABLE "schedule" ADD COLUMN "organizationId" text;--> statement-breakpoint
|
|
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
|
|
UPDATE "schedule" s
|
|
SET "organizationId" = m."organization_id"
|
|
FROM "member" m
|
|
WHERE s."scheduleType" = 'dokploy-server'
|
|
AND s."userId" = m."user_id"
|
|
AND m."role" = 'owner';--> statement-breakpoint
|
|
ALTER TABLE "schedule" DROP COLUMN "userId";
|