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

74 lines
5.7 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="sales_order" resource="sales">
<column xsi:type="timestamp" name="customer_confirmed_at" nullable="true"
on_update="false" comment="Customer Confirmed Receipt At"/>
</table>
<table name="esun_review_image" resource="default" engine="innodb" comment="Esun Review Images">
<column xsi:type="int" name="image_id" unsigned="true" nullable="false" identity="true" comment="Image ID"/>
<column xsi:type="bigint" name="review_id" unsigned="true" nullable="false" comment="Review ID"/>
<column xsi:type="int" name="customer_id" unsigned="true" nullable="true" comment="Customer ID"/>
<column xsi:type="varchar" name="image_path" nullable="false" length="1024" comment="Image Path"/>
<column xsi:type="varchar" name="thumbnail_path" nullable="true" length="1024" comment="Thumbnail Path"/>
<column xsi:type="varchar" name="media_type" nullable="false" length="16" default="image" comment="Media Type"/>
<column xsi:type="smallint" name="status" unsigned="true" nullable="false" default="1" comment="Status"/>
<column xsi:type="int" name="sort_order" nullable="false" default="0" comment="Sort Order"/>
<column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="image_id"/>
</constraint>
<constraint xsi:type="foreign" referenceId="ESUN_REVIEW_IMAGE_REVIEW_ID_REVIEW_REVIEW_ID"
table="esun_review_image" column="review_id"
referenceTable="review" referenceColumn="review_id"
onDelete="CASCADE"/>
<index referenceId="ESUN_REVIEW_IMAGE_REVIEW_STATUS_SORT" indexType="btree">
<column name="review_id"/>
<column name="status"/>
<column name="sort_order"/>
</index>
</table>
<table name="esun_review_vote" resource="default" engine="innodb" comment="Esun Review Helpful Votes">
<column xsi:type="int" name="vote_id" unsigned="true" nullable="false" identity="true" comment="Vote ID"/>
<column xsi:type="bigint" name="review_id" unsigned="true" nullable="false" comment="Review ID"/>
<column xsi:type="int" name="customer_id" unsigned="true" nullable="false" comment="Customer ID"/>
<column xsi:type="smallint" name="vote_type" nullable="false" comment="Vote Type"/>
<column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="vote_id"/>
</constraint>
<constraint xsi:type="unique" referenceId="ESUN_REVIEW_VOTE_REVIEW_CUSTOMER_UNQ">
<column name="review_id"/>
<column name="customer_id"/>
</constraint>
<constraint xsi:type="foreign" referenceId="ESUN_REVIEW_VOTE_REVIEW_ID_REVIEW_REVIEW_ID"
table="esun_review_vote" column="review_id"
referenceTable="review" referenceColumn="review_id"
onDelete="CASCADE"/>
<index referenceId="ESUN_REVIEW_VOTE_REVIEW_TYPE" indexType="btree">
<column name="review_id"/>
<column name="vote_type"/>
</index>
<index referenceId="ESUN_REVIEW_VOTE_CUSTOMER" indexType="btree">
<column name="customer_id"/>
</index>
</table>
<table name="esun_review_purchase" resource="default" engine="innodb" comment="eSUN Review Purchase Links">
<column xsi:type="int" name="purchase_review_id" unsigned="true" nullable="false" identity="true" comment="ID"/>
<column xsi:type="bigint" name="review_id" unsigned="true" nullable="false" comment="Review ID"/>
<column xsi:type="int" name="customer_id" unsigned="true" nullable="false" comment="Customer ID"/>
<column xsi:type="int" name="order_id" unsigned="true" nullable="false" comment="Order ID"/>
<column xsi:type="int" name="order_item_id" unsigned="true" nullable="false" comment="Order Item ID"/>
<column xsi:type="int" name="product_id" unsigned="true" nullable="false" comment="Product ID"/>
<column xsi:type="varchar" name="eligibility_type" nullable="false" length="32" default="payment_success" comment="Eligibility Type"/>
<column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
<constraint xsi:type="primary" referenceId="PRIMARY"><column name="purchase_review_id"/></constraint>
<constraint xsi:type="unique" referenceId="ESUN_REVIEW_PURCHASE_REVIEW_UNQ"><column name="review_id"/></constraint>
<constraint xsi:type="unique" referenceId="ESUN_REVIEW_PURCHASE_CUSTOMER_PRODUCT_UNQ"><column name="customer_id"/><column name="product_id"/></constraint>
<constraint xsi:type="foreign" referenceId="ESUN_REVIEW_PURCHASE_REVIEW_ID_REVIEW_REVIEW_ID" table="esun_review_purchase" column="review_id" referenceTable="review" referenceColumn="review_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="ESUN_REVIEW_PURCHASE_ORDER_ID_SALES_ORDER_ENTITY_ID" table="esun_review_purchase" column="order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="ESUN_REVIEW_PURCHASE_ORDER_ITEM_ID_SALES_ORDER_ITEM_ITEM_ID" table="esun_review_purchase" column="order_item_id" referenceTable="sales_order_item" referenceColumn="item_id" onDelete="CASCADE"/>
</table>
</schema>