db_schema.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <?xml version="1.0"?>
  2. <!--
  3. /**
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. -->
  8. <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9. xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
  10. <table name="review_entity" resource="default" engine="innodb" comment="Review entities">
  11. <column xsi:type="smallint" name="entity_id" padding="5" unsigned="true" nullable="false" identity="true"
  12. comment="Review entity id"/>
  13. <column xsi:type="varchar" name="entity_code" nullable="false" length="32" comment="Review entity code"/>
  14. <constraint xsi:type="primary" referenceId="PRIMARY">
  15. <column name="entity_id"/>
  16. </constraint>
  17. </table>
  18. <table name="review_status" resource="default" engine="innodb" comment="Review statuses">
  19. <column xsi:type="smallint" name="status_id" padding="5" unsigned="true" nullable="false" identity="true"
  20. comment="Status id"/>
  21. <column xsi:type="varchar" name="status_code" nullable="false" length="32" comment="Status code"/>
  22. <constraint xsi:type="primary" referenceId="PRIMARY">
  23. <column name="status_id"/>
  24. </constraint>
  25. </table>
  26. <table name="review" resource="default" engine="innodb" comment="Review base information">
  27. <column xsi:type="bigint" name="review_id" padding="20" unsigned="true" nullable="false" identity="true"
  28. comment="Review id"/>
  29. <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
  30. comment="Review create date"/>
  31. <column xsi:type="smallint" name="entity_id" padding="5" unsigned="true" nullable="false" identity="false"
  32. default="0" comment="Entity id"/>
  33. <column xsi:type="int" name="entity_pk_value" padding="10" unsigned="true" nullable="false" identity="false"
  34. default="0" comment="Product id"/>
  35. <column xsi:type="smallint" name="status_id" padding="5" unsigned="true" nullable="false" identity="false"
  36. default="0" comment="Status code"/>
  37. <constraint xsi:type="primary" referenceId="PRIMARY">
  38. <column name="review_id"/>
  39. </constraint>
  40. <constraint xsi:type="foreign" referenceId="REVIEW_ENTITY_ID_REVIEW_ENTITY_ENTITY_ID" table="review" column="entity_id"
  41. referenceTable="review_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
  42. <constraint xsi:type="foreign" referenceId="REVIEW_STATUS_ID_REVIEW_STATUS_STATUS_ID" table="review" column="status_id"
  43. referenceTable="review_status" referenceColumn="status_id" onDelete="NO ACTION"/>
  44. <index referenceId="REVIEW_ENTITY_ID" indexType="btree">
  45. <column name="entity_id"/>
  46. </index>
  47. <index referenceId="REVIEW_STATUS_ID" indexType="btree">
  48. <column name="status_id"/>
  49. </index>
  50. <index referenceId="REVIEW_ENTITY_PK_VALUE" indexType="btree">
  51. <column name="entity_pk_value"/>
  52. </index>
  53. </table>
  54. <table name="review_detail" resource="default" engine="innodb" comment="Review detail information">
  55. <column xsi:type="bigint" name="detail_id" padding="20" unsigned="true" nullable="false" identity="true"
  56. comment="Review detail id"/>
  57. <column xsi:type="bigint" name="review_id" padding="20" unsigned="true" nullable="false" identity="false"
  58. default="0" comment="Review id"/>
  59. <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="true" identity="false"
  60. default="0" comment="Store id"/>
  61. <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
  62. <column xsi:type="text" name="detail" nullable="false" comment="Detail description"/>
  63. <column xsi:type="varchar" name="nickname" nullable="false" length="128" comment="User nickname"/>
  64. <column xsi:type="int" name="customer_id" padding="10" unsigned="true" nullable="true" identity="false"
  65. comment="Customer Id"/>
  66. <constraint xsi:type="primary" referenceId="PRIMARY">
  67. <column name="detail_id"/>
  68. </constraint>
  69. <constraint xsi:type="foreign" referenceId="REVIEW_DETAIL_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="review_detail"
  70. column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id"
  71. onDelete="SET NULL"/>
  72. <constraint xsi:type="foreign" referenceId="REVIEW_DETAIL_REVIEW_ID_REVIEW_REVIEW_ID" table="review_detail"
  73. column="review_id" referenceTable="review" referenceColumn="review_id" onDelete="CASCADE"/>
  74. <constraint xsi:type="foreign" referenceId="REVIEW_DETAIL_STORE_ID_STORE_STORE_ID" table="review_detail"
  75. column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/>
  76. <index referenceId="REVIEW_DETAIL_REVIEW_ID" indexType="btree">
  77. <column name="review_id"/>
  78. </index>
  79. <index referenceId="REVIEW_DETAIL_STORE_ID" indexType="btree">
  80. <column name="store_id"/>
  81. </index>
  82. <index referenceId="REVIEW_DETAIL_CUSTOMER_ID" indexType="btree">
  83. <column name="customer_id"/>
  84. </index>
  85. </table>
  86. <table name="review_entity_summary" resource="default" engine="innodb" comment="Review aggregates">
  87. <column xsi:type="bigint" name="primary_id" padding="20" unsigned="false" nullable="false" identity="true"
  88. comment="Summary review entity id"/>
  89. <column xsi:type="bigint" name="entity_pk_value" padding="20" unsigned="false" nullable="false" identity="false"
  90. default="0" comment="Product id"/>
  91. <column xsi:type="smallint" name="entity_type" padding="6" unsigned="false" nullable="false" identity="false"
  92. default="0" comment="Entity type id"/>
  93. <column xsi:type="smallint" name="reviews_count" padding="6" unsigned="false" nullable="false" identity="false"
  94. default="0" comment="Qty of reviews"/>
  95. <column xsi:type="smallint" name="rating_summary" padding="6" unsigned="false" nullable="false" identity="false"
  96. default="0" comment="Summarized rating"/>
  97. <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
  98. default="0" comment="Store ID"/>
  99. <constraint xsi:type="primary" referenceId="PRIMARY">
  100. <column name="primary_id"/>
  101. </constraint>
  102. <constraint xsi:type="foreign" referenceId="REVIEW_ENTITY_SUMMARY_STORE_ID_STORE_STORE_ID"
  103. table="review_entity_summary" column="store_id" referenceTable="store" referenceColumn="store_id"
  104. onDelete="CASCADE"/>
  105. <index referenceId="REVIEW_ENTITY_SUMMARY_STORE_ID" indexType="btree">
  106. <column name="store_id"/>
  107. </index>
  108. </table>
  109. <table name="review_store" resource="default" engine="innodb" comment="Review Store">
  110. <column xsi:type="bigint" name="review_id" padding="20" unsigned="true" nullable="false" identity="false"
  111. comment="Review ID"/>
  112. <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
  113. comment="Store ID"/>
  114. <constraint xsi:type="primary" referenceId="PRIMARY">
  115. <column name="review_id"/>
  116. <column name="store_id"/>
  117. </constraint>
  118. <constraint xsi:type="foreign" referenceId="REVIEW_STORE_REVIEW_ID_REVIEW_REVIEW_ID" table="review_store"
  119. column="review_id" referenceTable="review" referenceColumn="review_id" onDelete="CASCADE"/>
  120. <constraint xsi:type="foreign" referenceId="REVIEW_STORE_STORE_ID_STORE_STORE_ID" table="review_store"
  121. column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
  122. <index referenceId="REVIEW_STORE_STORE_ID" indexType="btree">
  123. <column name="store_id"/>
  124. </index>
  125. </table>
  126. <table name="rating_entity" resource="default" engine="innodb" comment="Rating entities">
  127. <column xsi:type="smallint" name="entity_id" padding="5" unsigned="true" nullable="false" identity="true"
  128. comment="Entity ID"/>
  129. <column xsi:type="varchar" name="entity_code" nullable="false" length="64" comment="Entity Code"/>
  130. <constraint xsi:type="primary" referenceId="PRIMARY">
  131. <column name="entity_id"/>
  132. </constraint>
  133. <constraint xsi:type="unique" referenceId="RATING_ENTITY_ENTITY_CODE">
  134. <column name="entity_code"/>
  135. </constraint>
  136. </table>
  137. <table name="rating" resource="default" engine="innodb" comment="Ratings">
  138. <column xsi:type="smallint" name="rating_id" padding="5" unsigned="true" nullable="false" identity="true"
  139. comment="Rating ID"/>
  140. <column xsi:type="smallint" name="entity_id" padding="5" unsigned="true" nullable="false" identity="false"
  141. default="0" comment="Entity ID"/>
  142. <column xsi:type="varchar" name="rating_code" nullable="false" length="64" comment="Rating Code"/>
  143. <column xsi:type="smallint" name="position" padding="5" unsigned="true" nullable="false" identity="false"
  144. default="0" comment="Rating Position On Storefront"/>
  145. <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false"
  146. default="1" comment="Rating is active."/>
  147. <constraint xsi:type="primary" referenceId="PRIMARY">
  148. <column name="rating_id"/>
  149. </constraint>
  150. <constraint xsi:type="foreign" referenceId="RATING_ENTITY_ID_RATING_ENTITY_ENTITY_ID" table="rating" column="entity_id"
  151. referenceTable="rating_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
  152. <constraint xsi:type="unique" referenceId="RATING_RATING_CODE">
  153. <column name="rating_code"/>
  154. </constraint>
  155. <index referenceId="RATING_ENTITY_ID" indexType="btree">
  156. <column name="entity_id"/>
  157. </index>
  158. </table>
  159. <table name="rating_option" resource="default" engine="innodb" comment="Rating options">
  160. <column xsi:type="int" name="option_id" padding="10" unsigned="true" nullable="false" identity="true"
  161. comment="Rating Option Id"/>
  162. <column xsi:type="smallint" name="rating_id" padding="5" unsigned="true" nullable="false" identity="false"
  163. default="0" comment="Rating Id"/>
  164. <column xsi:type="varchar" name="code" nullable="false" length="32" comment="Rating Option Code"/>
  165. <column xsi:type="smallint" name="value" padding="5" unsigned="true" nullable="false" identity="false"
  166. default="0" comment="Rating Option Value"/>
  167. <column xsi:type="smallint" name="position" padding="5" unsigned="true" nullable="false" identity="false"
  168. default="0" comment="Ration option position on Storefront"/>
  169. <constraint xsi:type="primary" referenceId="PRIMARY">
  170. <column name="option_id"/>
  171. </constraint>
  172. <constraint xsi:type="foreign" referenceId="RATING_OPTION_RATING_ID_RATING_RATING_ID" table="rating_option"
  173. column="rating_id" referenceTable="rating" referenceColumn="rating_id" onDelete="CASCADE"/>
  174. <index referenceId="RATING_OPTION_RATING_ID" indexType="btree">
  175. <column name="rating_id"/>
  176. </index>
  177. </table>
  178. <table name="rating_option_vote" resource="default" engine="innodb" comment="Rating option values">
  179. <column xsi:type="bigint" name="vote_id" padding="20" unsigned="true" nullable="false" identity="true"
  180. comment="Vote id"/>
  181. <column xsi:type="int" name="option_id" padding="10" unsigned="true" nullable="false" identity="false"
  182. default="0" comment="Vote option id"/>
  183. <column xsi:type="varchar" name="remote_ip" nullable="false" length="16" comment="Customer IP"/>
  184. <column xsi:type="bigint" name="remote_ip_long" padding="20" unsigned="false" nullable="false" identity="false"
  185. default="0" comment="Customer IP converted to long integer format"/>
  186. <column xsi:type="int" name="customer_id" padding="10" unsigned="true" nullable="true" identity="false"
  187. default="0" comment="Customer Id"/>
  188. <column xsi:type="bigint" name="entity_pk_value" padding="20" unsigned="true" nullable="false" identity="false"
  189. default="0" comment="Product id"/>
  190. <column xsi:type="smallint" name="rating_id" padding="5" unsigned="true" nullable="false" identity="false"
  191. default="0" comment="Rating id"/>
  192. <column xsi:type="bigint" name="review_id" padding="20" unsigned="true" nullable="true" identity="false"
  193. comment="Review id"/>
  194. <column xsi:type="smallint" name="percent" padding="6" unsigned="false" nullable="false" identity="false"
  195. default="0" comment="Percent amount"/>
  196. <column xsi:type="smallint" name="value" padding="6" unsigned="false" nullable="false" identity="false"
  197. default="0" comment="Vote option value"/>
  198. <constraint xsi:type="primary" referenceId="PRIMARY">
  199. <column name="vote_id"/>
  200. </constraint>
  201. <constraint xsi:type="foreign" referenceId="RATING_OPTION_VOTE_OPTION_ID_RATING_OPTION_OPTION_ID"
  202. table="rating_option_vote" column="option_id" referenceTable="rating_option"
  203. referenceColumn="option_id" onDelete="CASCADE"/>
  204. <constraint xsi:type="foreign" referenceId="RATING_OPTION_VOTE_REVIEW_ID_REVIEW_REVIEW_ID" table="rating_option_vote"
  205. column="review_id" referenceTable="review" referenceColumn="review_id" onDelete="CASCADE"/>
  206. <index referenceId="RATING_OPTION_VOTE_OPTION_ID" indexType="btree">
  207. <column name="option_id"/>
  208. </index>
  209. </table>
  210. <table name="rating_option_vote_aggregated" resource="default" engine="innodb" comment="Rating vote aggregated">
  211. <column xsi:type="int" name="primary_id" padding="11" unsigned="false" nullable="false" identity="true"
  212. comment="Vote aggregation id"/>
  213. <column xsi:type="smallint" name="rating_id" padding="5" unsigned="true" nullable="false" identity="false"
  214. default="0" comment="Rating id"/>
  215. <column xsi:type="bigint" name="entity_pk_value" padding="20" unsigned="true" nullable="false" identity="false"
  216. default="0" comment="Product id"/>
  217. <column xsi:type="int" name="vote_count" padding="10" unsigned="true" nullable="false" identity="false"
  218. default="0" comment="Vote dty"/>
  219. <column xsi:type="int" name="vote_value_sum" padding="10" unsigned="true" nullable="false" identity="false"
  220. default="0" comment="General vote sum"/>
  221. <column xsi:type="smallint" name="percent" padding="6" unsigned="false" nullable="false" identity="false"
  222. default="0" comment="Vote percent"/>
  223. <column xsi:type="smallint" name="percent_approved" padding="6" unsigned="false" nullable="true"
  224. identity="false" default="0" comment="Vote percent approved by admin"/>
  225. <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
  226. default="0" comment="Store Id"/>
  227. <constraint xsi:type="primary" referenceId="PRIMARY">
  228. <column name="primary_id"/>
  229. </constraint>
  230. <constraint xsi:type="foreign" referenceId="RATING_OPTION_VOTE_AGGREGATED_RATING_ID_RATING_RATING_ID"
  231. table="rating_option_vote_aggregated" column="rating_id" referenceTable="rating"
  232. referenceColumn="rating_id" onDelete="CASCADE"/>
  233. <constraint xsi:type="foreign" referenceId="RATING_OPTION_VOTE_AGGREGATED_STORE_ID_STORE_STORE_ID"
  234. table="rating_option_vote_aggregated" column="store_id" referenceTable="store"
  235. referenceColumn="store_id" onDelete="CASCADE"/>
  236. <index referenceId="RATING_OPTION_VOTE_AGGREGATED_RATING_ID" indexType="btree">
  237. <column name="rating_id"/>
  238. </index>
  239. <index referenceId="RATING_OPTION_VOTE_AGGREGATED_STORE_ID" indexType="btree">
  240. <column name="store_id"/>
  241. </index>
  242. </table>
  243. <table name="rating_store" resource="default" engine="innodb" comment="Rating Store">
  244. <column xsi:type="smallint" name="rating_id" padding="5" unsigned="true" nullable="false" identity="false"
  245. default="0" comment="Rating id"/>
  246. <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
  247. default="0" comment="Store id"/>
  248. <constraint xsi:type="primary" referenceId="PRIMARY">
  249. <column name="rating_id"/>
  250. <column name="store_id"/>
  251. </constraint>
  252. <constraint xsi:type="foreign" referenceId="RATING_STORE_STORE_ID_STORE_STORE_ID" table="rating_store"
  253. column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
  254. <constraint xsi:type="foreign" referenceId="RATING_STORE_RATING_ID_RATING_RATING_ID" table="rating_store"
  255. column="rating_id" referenceTable="rating" referenceColumn="rating_id" onDelete="CASCADE"/>
  256. <index referenceId="RATING_STORE_STORE_ID" indexType="btree">
  257. <column name="store_id"/>
  258. </index>
  259. </table>
  260. <table name="rating_title" resource="default" engine="innodb" comment="Rating Title">
  261. <column xsi:type="smallint" name="rating_id" padding="5" unsigned="true" nullable="false" identity="false"
  262. default="0" comment="Rating Id"/>
  263. <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
  264. default="0" comment="Store Id"/>
  265. <column xsi:type="varchar" name="value" nullable="false" length="255" comment="Rating Label"/>
  266. <constraint xsi:type="primary" referenceId="PRIMARY">
  267. <column name="rating_id"/>
  268. <column name="store_id"/>
  269. </constraint>
  270. <constraint xsi:type="foreign" referenceId="RATING_TITLE_RATING_ID_RATING_RATING_ID" table="rating_title"
  271. column="rating_id" referenceTable="rating" referenceColumn="rating_id" onDelete="CASCADE"/>
  272. <constraint xsi:type="foreign" referenceId="RATING_TITLE_STORE_ID_STORE_STORE_ID" table="rating_title"
  273. column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/>
  274. <index referenceId="RATING_TITLE_STORE_ID" indexType="btree">
  275. <column name="store_id"/>
  276. </index>
  277. </table>
  278. </schema>