Skip to content

Can't create foreignKey with Declarative Schema on table not created through DS #21770

@peterjaap

Description

@peterjaap

Preconditions (*)

  1. Magento 2.3.0

Steps to reproduce (*)

  1. Create a module that uses Declarative Schema by creating a db_schema.xml
  2. Try to create a foreignKey with as referenceTable a table that isn't created/controlled through Declarative Schema (in my case a 3rd party extension's table)
  3. Run php bin/magento setup:upgrade

Expected result (*)

  1. Table is created with a foreign key to referenced table

Actual result (*)

  1. Error Notice: Undefined index: referenced_table_name_here in vendor/magento/framework/Setup/Declaration/Schema/Declaration/SchemaBuilder.php on line 352

When I edit vendor/magento/framework/Setup/Declaration/Schema/SchemaConfig.php:77 and add print_r(array_keys($data['table']));exit; there, I get a list of all tables created by extensions that use Declarative Schema. The referenced table isn't one of them and thus setup:upgrade throws an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: Framework/SetupUSE ONLY for FRAMEWORK RELATED BUG! E.g If bug occurs during Catalog Setup use just CatalogIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedProgress: doneReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject itbug reportfeature request

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions