Skip to content

Validation Error in doctrine:schema:validate After Merging PR #6418 #6437

Closed
@berkut1

Description

Bug Report

Q A
Version 3.8.5 and 4.0.3

Summary

The PR #6418 breaks doctrine:schema:validate and prevents validation, suggesting replacing all CONSTRAINT definitions, especially those with the FOREIGN KEY.

Removing the problematic line resolves the issue:

if (strtolower($key1->getName()) !== strtolower($key2->getName())) {
return true;
}

Current behaviour

doctrine:schema:validate fails validation and suggests replacing all foreign key CONSTRAINT definitions that include the FOREIGN KEY.

How to reproduce

Run doctrine:schema:validate
Observe the validation errors related to foreign key CONSTRAINT definitions with FOREIGN KEY

Example configuration causing the issue:

CREATE TABLE "cp_packages" (
            "id_package"    UUID NOT NULL, 
            "name"          VARCHAR(128) NOT NULL,
            "package_type"  VARCHAR(512) NOT NULL,
            CONSTRAINT "pk_cp_packages" PRIMARY KEY ("id_package")                         
            )

CREATE TABLE "cp_package_virtual_machines" (
            "id_package"    UUID NOT NULL,
            -- some attributes 
            CONSTRAINT "pk_cp_package_virtual_machines" PRIMARY KEY ("id_package"),
            CONSTRAINT "id_package_cp_package_virtual_machines" FOREIGN KEY ("id_package")
                     REFERENCES "cp_packages"("id_package") ON DELETE CASCADE                         
            )

validation schema errors

Mapping
-------                                                                                                                        
 [OK] The mapping files are correct.     

Database
--------
                                                                                                                        
 [ERROR] The database schema is not in sync with the current mapping file.                                              

ALTER TABLE cp_package_virtual_machines DROP CONSTRAINT id_package_cp_package_virtual_machines;
ALTER TABLE cp_package_virtual_machines ADD CONSTRAINT FK_D8247456F5CEE5 FOREIGN KEY (id_package) REFERENCES cp_packages (id_package) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
                                                                                                                        

It also completely ignores the ON DELETE RESTRICT rule, completely removing it. Re-tested that is not true.

Expected behaviour

doctrine:schema:validate should successfully validate the schema without suggesting changes to CONSTRAINT definitions, including those with the FOREIGN KEY

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions