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

59 lines
6.3 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_seventeen_track" resource="sales" engine="innodb" comment="17TRACK Shipment Status">
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true" comment="ID"/>
<column xsi:type="int" name="shipment_track_id" unsigned="true" nullable="false" comment="Magento Shipment Track ID"/>
<column xsi:type="int" name="shipment_id" unsigned="true" nullable="false" comment="Shipment ID"/>
<column xsi:type="int" name="order_id" unsigned="true" nullable="false" comment="Order ID"/>
<column xsi:type="varchar" name="tracking_number" nullable="false" length="50" comment="Tracking Number"/>
<column xsi:type="int" name="carrier_code" unsigned="true" nullable="true" comment="17TRACK Carrier Code"/>
<column xsi:type="varchar" name="sync_status" nullable="false" length="20" default="pending" comment="Sync Status"/>
<column xsi:type="int" name="error_code" nullable="true" comment="Last 17TRACK Error Code"/>
<column xsi:type="smallint" name="attempt_count" unsigned="true" nullable="false" default="0" comment="Consecutive Failure Count"/>
<column xsi:type="timestamp" name="next_attempt_at" nullable="true" on_update="false" comment="Next Attempt Time"/>
<column xsi:type="varchar" name="package_status" nullable="true" length="40" comment="17TRACK Package Status"/>
<column xsi:type="varchar" name="latest_event" nullable="true" length="1024" comment="Latest Tracking Event"/>
<column xsi:type="timestamp" name="delivered_at" nullable="true" on_update="false" comment="Delivery Time"/>
<column xsi:type="text" name="last_error" nullable="true" comment="Last Error"/>
<column xsi:type="mediumtext" name="response_data" nullable="true" comment="Last API Response"/>
<column xsi:type="timestamp" name="last_synced_at" nullable="true" on_update="false" comment="Last Sync Time"/>
<column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP" on_update="false" comment="Created At"/>
<column xsi:type="timestamp" name="updated_at" nullable="false" default="CURRENT_TIMESTAMP" on_update="true" comment="Updated At"/>
<constraint xsi:type="primary" referenceId="PRIMARY"><column name="entity_id"/></constraint>
<constraint xsi:type="unique" referenceId="ESUN_17TRACK_SHIPMENT_TRACK_UNQ"><column name="shipment_track_id"/></constraint>
<constraint xsi:type="foreign" referenceId="ESUN_17TRACK_SHIPMENT_TRACK_FK" table="esun_seventeen_track" column="shipment_track_id" referenceTable="sales_shipment_track" referenceColumn="entity_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="ESUN_17TRACK_SHIPMENT_FK" table="esun_seventeen_track" column="shipment_id" referenceTable="sales_shipment" referenceColumn="entity_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="ESUN_17TRACK_ORDER_FK" table="esun_seventeen_track" column="order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/>
<index referenceId="ESUN_17TRACK_SYNC_STATUS" indexType="btree"><column name="sync_status"/></index>
<index referenceId="ESUN_17TRACK_NEXT_ATTEMPT" indexType="btree"><column name="next_attempt_at"/></index>
<index referenceId="ESUN_17TRACK_ORDER_STATUS" indexType="btree"><column name="order_id"/><column name="package_status"/></index>
</table>
<table name="esun_seventeen_track_api_log" resource="sales" engine="innodb" comment="17TRACK API Audit Log">
<column xsi:type="bigint" name="entity_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
<column xsi:type="varchar" name="direction" nullable="false" length="10" comment="Inbound or Outbound"/>
<column xsi:type="varchar" name="operation" nullable="false" length="30" comment="API Operation"/>
<column xsi:type="varchar" name="api_path" nullable="true" length="255" comment="API Endpoint"/>
<column xsi:type="varchar" name="batch_id" nullable="true" length="32" comment="Batch Correlation ID"/>
<column xsi:type="int" name="order_id" unsigned="true" nullable="true" comment="Magento Order ID"/>
<column xsi:type="varchar" name="order_number" nullable="true" length="50" comment="Magento Order Number"/>
<column xsi:type="varchar" name="tracking_number" nullable="true" length="50" comment="Tracking Number"/>
<column xsi:type="varchar" name="event" nullable="true" length="50" comment="Webhook Event"/>
<column xsi:type="varchar" name="status" nullable="false" length="20" comment="Result Status"/>
<column xsi:type="smallint" name="http_status" unsigned="true" nullable="true" comment="HTTP Status"/>
<column xsi:type="int" name="error_code" nullable="true" comment="17TRACK Error Code"/>
<column xsi:type="text" name="message" nullable="true" comment="Result or Error Message"/>
<column xsi:type="mediumtext" name="request_data" nullable="true" comment="Sanitized Request Data"/>
<column xsi:type="mediumtext" name="response_data" nullable="true" comment="Sanitized Response Data"/>
<column xsi:type="int" name="duration_ms" unsigned="true" nullable="true" comment="Duration Milliseconds"/>
<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>
<index referenceId="ESUN_17TRACK_API_LOG_STATUS_CREATED" indexType="btree"><column name="status"/><column name="created_at"/></index>
<index referenceId="ESUN_17TRACK_API_LOG_OPERATION_CREATED" indexType="btree"><column name="operation"/><column name="created_at"/></index>
<index referenceId="ESUN_17TRACK_API_LOG_ORDER" indexType="btree"><column name="order_number"/></index>
<index referenceId="ESUN_17TRACK_API_LOG_TRACKING" indexType="btree"><column name="tracking_number"/></index>
<index referenceId="ESUN_17TRACK_API_LOG_BATCH" indexType="btree"><column name="batch_id"/></index>
</table>
</schema>