Last active
February 17, 2023 14:53
-
-
Save WalterWoshid/5055179b29d74f17b6ca025fde803865 to your computer and use it in GitHub Desktop.
Magento 2: Many-to-Many-Relationship - db_schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> | |
... | |
<table name="custom_blog_product_blog_relation" resource="default" engine="innodb" comment="Product to Blog Relation Table"> | |
<column xsi:type="int" name="relation_id" padding="10" identity="true" | |
unsigned="true" nullable="false" comment="Entity ID"/> | |
<column xsi:type="int" name="product_id" padding="10" identity="false" | |
unsigned="true" nullable="false" comment="Related Product ID"/> | |
<column xsi:type="int" name="blog_id" padding="10" identity="false" | |
unsigned="true" nullable="false" comment="Related Blog ID"/> | |
<constraint xsi:type="primary" referenceId="PRIMARY"> | |
<column name="relation_id"/> | |
<column name="product_id"/> | |
<column name="blog_id"/> | |
</constraint> | |
<constraint xsi:type="foreign" referenceId="PROD_BLOG_REL_PROD_ID_PROD_ID" | |
table="custom_blog_product_blog_relation" column="product_id" | |
referenceTable="catalog_product_entity" referenceColumn="entity_id" | |
onDelete="CASCADE"/> | |
<constraint xsi:type="foreign" referenceId="PROD_BLOG_REL_BLOG_ID_BLOG_ID" | |
table="custom_blog_product_blog_relation" column="blog_id" | |
referenceTable="custom_blog" referenceColumn="blog_id" | |
onDelete="CASCADE"/> | |
<constraint xsi:type="unique" referenceId="PROD_BLOG_REL_PROD_ID_BLOG_ID_KEY"> | |
<column name="product_id"/> | |
<column name="blog_id"/> | |
</constraint> | |
<index referenceId="PROD_BLOG_REL_PROD_ID_INDEX" indexType="btree"> | |
<column name="product_id"/> | |
</index> | |
</table> | |
... | |
</schema> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment