Link to reproduction
No response
Payload Version
3.0.0-beta63
Node Version
22.4.1
Next.js Version
15.0-rc0
Describe the Bug
Patching a collection entry fails, when patching an identifier, referenced as a foreign key in a different table, since the default migration settings do not set a cascade permission. Patch operation responds with a success message, however no changes were made.
Example of migration:
CREATE TABLE IF NOT EXISTS "media" (
"id" serial PRIMARY KEY NOT NULL,
"alt" varchar NOT NULL,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"url" varchar,
"thumbnail_u_r_l" varchar,
"filename" varchar,
"mime_type" varchar,
"filesize" numeric,
"width" numeric,
"height" numeric,
"focal_x" numeric,
"focal_y" numeric
);
CREATE TABLE IF NOT EXISTS "properties_images" (
"_order" integer NOT NULL,
"_parent_id" varchar NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"image_id" integer NOT NULL
);
CREATE TABLE IF NOT EXISTS "properties" (
"id" varchar PRIMARY KEY NOT NULL,
"title" varchar NOT NULL,
"desciption" varchar NOT NULL,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
);
DO $$ BEGIN
ALTER TABLE "properties_images" ADD CONSTRAINT "properties_images_image_id_media_id_fk" FOREIGN KEY ("image_id") REFERENCES "media"("id") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
DO $$ BEGIN
ALTER TABLE "properties_images" ADD CONSTRAINT "properties_images_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "properties"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
Allowing this to cascade on update should fix the issue
Reproduction Steps
- Create a schema, with a reference to a media entry
- Create a new entry, with an attached media object
- Attempt to update the unique identifier, that the media object references as a parent_id
Adapters and Plugins
db-postgres
Link to reproduction
No response
Payload Version
3.0.0-beta63
Node Version
22.4.1
Next.js Version
15.0-rc0
Describe the Bug
Patching a collection entry fails, when patching an identifier, referenced as a foreign key in a different table, since the default migration settings do not set a cascade permission. Patch operation responds with a success message, however no changes were made.
Example of migration:
Allowing this to cascade on update should fix the issue
Reproduction Steps
Adapters and Plugins
db-postgres