Files
2026-09-15 10:35:56 +08:00

49 lines
2.8 KiB
XML

<?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="esun_customer_coupon" resource="default" engine="innodb"
comment="Customer Assigned Coupon">
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true"
comment="Entity ID"/>
<column xsi:type="int" name="coupon_id" unsigned="true" nullable="false"
comment="Coupon ID"/>
<column xsi:type="int" name="rule_id" unsigned="true" nullable="false"
comment="Sales Rule ID"/>
<column xsi:type="int" name="customer_id" unsigned="true" nullable="false"
comment="Customer ID"/>
<column xsi:type="varchar" name="source" nullable="true" length="64"
comment="Assignment Source"/>
<column xsi:type="timestamp" name="assigned_at" nullable="false" default="CURRENT_TIMESTAMP"
on_update="false" comment="Assigned At"/>
<column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP"
on_update="false" comment="Created At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="entity_id"/>
</constraint>
<constraint xsi:type="unique" referenceId="ESUN_CUSTOMER_COUPON_COUPON_ID_UNQ">
<column name="coupon_id"/>
</constraint>
<constraint xsi:type="unique" referenceId="ESUN_CUSTOMER_COUPON_CUSTOMER_ID_SOURCE_UNQ">
<column name="customer_id"/>
<column name="source"/>
</constraint>
<constraint xsi:type="foreign" referenceId="ESUN_CUSTOMER_COUPON_COUPON_ID_SALESRULE_COUPON_COUPON_ID"
table="esun_customer_coupon" column="coupon_id"
referenceTable="salesrule_coupon" referenceColumn="coupon_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="ESUN_CUSTOMER_COUPON_RULE_ID_SALESRULE_RULE_ID"
table="esun_customer_coupon" column="rule_id"
referenceTable="salesrule" referenceColumn="rule_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="ESUN_CUSTOMER_COUPON_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID"
table="esun_customer_coupon" column="customer_id"
referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
<index referenceId="ESUN_CUSTOMER_COUPON_CUSTOMER_ID_COUPON_ID" indexType="btree">
<column name="customer_id"/>
<column name="coupon_id"/>
</index>
<index referenceId="ESUN_CUSTOMER_COUPON_RULE_ID" indexType="btree">
<column name="rule_id"/>
</index>
</table>
</schema>