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:
dbal/src/Schema/Comparator.php
Lines 374 to 376 in 8edbce7
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 Re-tested that is not true.ON DELETE RESTRICT
rule, completely removing it.
Expected behaviour
doctrine:schema:validate
should successfully validate the schema without suggesting changes to CONSTRAINT
definitions, including those with the FOREIGN KEY
Activity