mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-11 06:25:17 +00:00
- Changed the SQL update statement to directly select the owner_id from the organization table instead of joining with the account table, simplifying the query.
14 lines
714 B
SQL
14 lines
714 B
SQL
ALTER TABLE "git_provider" ADD COLUMN "userId" text;--> statement-breakpoint
|
|
|
|
-- Update existing git providers to be owned by the organization owner
|
|
-- We can get the owner_id directly from the organization table
|
|
UPDATE "git_provider"
|
|
SET "userId" = (
|
|
SELECT o."owner_id"
|
|
FROM "organization" o
|
|
WHERE o.id = "git_provider"."organizationId"
|
|
);--> statement-breakpoint
|
|
|
|
-- Now make the column NOT NULL since all rows should have values
|
|
ALTER TABLE "git_provider" ALTER COLUMN "userId" SET NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE "git_provider" ADD CONSTRAINT "git_provider_userId_user_temp_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user_temp"("id") ON DELETE cascade ON UPDATE no action; |