magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.3k forks source link

Missing "RESTRICT" value to declarative schema foreign constraint #27072

Open textarea opened 4 years ago

textarea commented 4 years ago

Summary (*)

Cannot set a foreign constraint onDelete="RESTRICT" in custom table.

Examples (*)

<constraint xsi:type="foreign"
    referenceId="CUSTOM_TABLE_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID"
    table="custom_table"
    column="customer_id"
    referenceTable="customer_entity"
    referenceColumn="entity_id"
    onDelete="RESTRICT"/>

Proposed solution

Add "RESTRICT" value to foreign constraint referenceOptionsType.

m2-assistant[bot] commented 4 years ago

Hi @textarea. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@textarea do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?


m2-assistant[bot] commented 4 years ago

Hi @dmytro-ch. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

magento-engcom-team commented 4 years ago

:white_check_mark: Confirmed by @dmytro-ch Thank you for verifying the issue. Based on the provided information internal tickets MC-31998 were created

Issue Available: @dmytro-ch, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

sdzhepa commented 4 years ago

Hello @textarea fyi: @dmytro-ch

Could you please provide more details about the use cases and business value of this issue or what dev experience it will improve and how?

textarea commented 4 years ago

Hello @sdzhepa,

I'm sorry but I will not provide more details about the use cases and business value, or about improved dev experience this issue can bring.

When I build a database schema I use all the tools the RDBMS makes available according to my needs.

Magento 2.3 declarative schema misses some foreign key constraints that are supported by standards RDBMS.

Best regards

speller commented 5 months ago

Any updates on this issue?

speller commented 5 months ago

That's funny how a one-line fix ticket is not being solved for 4 years. Just add the <xs:enumeration value="RESTRICT" /> line to the Setup/Declaration/Schema/etc/constraints/foreign.xsd file and that's it.