db_schema.xml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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="oauth_consumer" resource="default" engine="innodb" comment="OAuth Consumers">
  11. <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true"
  12. comment="Entity ID"/>
  13. <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
  14. comment="Created At"/>
  15. <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="true" default="0"
  16. comment="Updated At"/>
  17. <column xsi:type="varchar" name="name" nullable="false" length="255" comment="Name of consumer"/>
  18. <column xsi:type="varchar" name="key" nullable="false" length="32" comment="Key code"/>
  19. <column xsi:type="varchar" name="secret" nullable="false" length="32" comment="Secret code"/>
  20. <column xsi:type="text" name="callback_url" nullable="true" comment="Callback URL"/>
  21. <column xsi:type="text" name="rejected_callback_url" nullable="false" comment="Rejected callback URL"/>
  22. <constraint xsi:type="primary" referenceId="PRIMARY">
  23. <column name="entity_id"/>
  24. </constraint>
  25. <constraint xsi:type="unique" referenceId="OAUTH_CONSUMER_KEY">
  26. <column name="key"/>
  27. </constraint>
  28. <constraint xsi:type="unique" referenceId="OAUTH_CONSUMER_SECRET">
  29. <column name="secret"/>
  30. </constraint>
  31. <index referenceId="OAUTH_CONSUMER_CREATED_AT" indexType="btree">
  32. <column name="created_at"/>
  33. </index>
  34. <index referenceId="OAUTH_CONSUMER_UPDATED_AT" indexType="btree">
  35. <column name="updated_at"/>
  36. </index>
  37. </table>
  38. <table name="oauth_token" resource="default" engine="innodb" comment="OAuth Tokens">
  39. <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true"
  40. comment="Entity ID"/>
  41. <column xsi:type="int" name="consumer_id" padding="10" unsigned="true" nullable="true" identity="false"
  42. comment="Oauth Consumer ID"/>
  43. <column xsi:type="int" name="admin_id" padding="10" unsigned="true" nullable="true" identity="false"
  44. comment="Admin user ID"/>
  45. <column xsi:type="int" name="customer_id" padding="10" unsigned="true" nullable="true" identity="false"
  46. comment="Customer user ID"/>
  47. <column xsi:type="varchar" name="type" nullable="false" length="16" comment="Token Type"/>
  48. <column xsi:type="varchar" name="token" nullable="false" length="32" comment="Token"/>
  49. <column xsi:type="varchar" name="secret" nullable="false" length="32" comment="Token Secret"/>
  50. <column xsi:type="varchar" name="verifier" nullable="true" length="32" comment="Token Verifier"/>
  51. <column xsi:type="text" name="callback_url" nullable="false" comment="Token Callback URL"/>
  52. <column xsi:type="smallint" name="revoked" padding="5" unsigned="true" nullable="false" identity="false"
  53. default="0" comment="Is Token revoked"/>
  54. <column xsi:type="smallint" name="authorized" padding="5" unsigned="true" nullable="false" identity="false"
  55. default="0" comment="Is Token authorized"/>
  56. <column xsi:type="int" name="user_type" padding="11" unsigned="false" nullable="true" identity="false"
  57. comment="User type"/>
  58. <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
  59. comment="Token creation timestamp"/>
  60. <constraint xsi:type="primary" referenceId="PRIMARY">
  61. <column name="entity_id"/>
  62. </constraint>
  63. <constraint xsi:type="foreign" referenceId="OAUTH_TOKEN_ADMIN_ID_ADMIN_USER_USER_ID" table="oauth_token"
  64. column="admin_id" referenceTable="admin_user" referenceColumn="user_id" onDelete="CASCADE"/>
  65. <constraint xsi:type="foreign" referenceId="OAUTH_TOKEN_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID" table="oauth_token"
  66. column="consumer_id" referenceTable="oauth_consumer" referenceColumn="entity_id"
  67. onDelete="CASCADE"/>
  68. <constraint xsi:type="foreign" referenceId="OAUTH_TOKEN_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="oauth_token"
  69. column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id"
  70. onDelete="CASCADE"/>
  71. <constraint xsi:type="unique" referenceId="OAUTH_TOKEN_TOKEN">
  72. <column name="token"/>
  73. </constraint>
  74. <index referenceId="OAUTH_TOKEN_CONSUMER_ID" indexType="btree">
  75. <column name="consumer_id"/>
  76. </index>
  77. </table>
  78. <table name="oauth_nonce" resource="default" engine="innodb" comment="OAuth Nonce">
  79. <column xsi:type="varchar" name="nonce" nullable="false" length="32" comment="Nonce String"/>
  80. <column xsi:type="int" name="timestamp" padding="10" unsigned="true" nullable="false" identity="false"
  81. comment="Nonce Timestamp"/>
  82. <column xsi:type="int" name="consumer_id" padding="10" unsigned="true" nullable="false" identity="false"
  83. comment="Consumer ID"/>
  84. <constraint xsi:type="foreign" referenceId="OAUTH_NONCE_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID" table="oauth_nonce"
  85. column="consumer_id" referenceTable="oauth_consumer" referenceColumn="entity_id"
  86. onDelete="CASCADE"/>
  87. <constraint xsi:type="unique" referenceId="OAUTH_NONCE_NONCE_CONSUMER_ID">
  88. <column name="nonce"/>
  89. <column name="consumer_id"/>
  90. </constraint>
  91. <index referenceId="OAUTH_NONCE_TIMESTAMP" indexType="btree">
  92. <column name="timestamp"/>
  93. </index>
  94. </table>
  95. <table name="integration" resource="default" engine="innodb" comment="integration">
  96. <column xsi:type="int" name="integration_id" padding="10" unsigned="true" nullable="false" identity="true"
  97. comment="Integration ID"/>
  98. <column xsi:type="varchar" name="name" nullable="false" length="255"
  99. comment="Integration name is displayed in the admin interface"/>
  100. <column xsi:type="varchar" name="email" nullable="false" length="255"
  101. comment="Email address of the contact person"/>
  102. <column xsi:type="varchar" name="endpoint" nullable="true" length="255"
  103. comment="Endpoint for posting consumer credentials"/>
  104. <column xsi:type="smallint" name="status" padding="5" unsigned="true" nullable="false" identity="false"
  105. comment="Integration status"/>
  106. <column xsi:type="int" name="consumer_id" padding="10" unsigned="true" nullable="true" identity="false"
  107. comment="Oauth consumer"/>
  108. <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
  109. comment="Creation Time"/>
  110. <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="0"
  111. comment="Update Time"/>
  112. <column xsi:type="smallint" name="setup_type" padding="5" unsigned="true" nullable="false" identity="false"
  113. default="0" comment="Integration type - manual or config file"/>
  114. <column xsi:type="varchar" name="identity_link_url" nullable="true" length="255"
  115. comment="Identity linking Url"/>
  116. <constraint xsi:type="primary" referenceId="PRIMARY">
  117. <column name="integration_id"/>
  118. </constraint>
  119. <constraint xsi:type="foreign" referenceId="INTEGRATION_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID" table="integration"
  120. column="consumer_id" referenceTable="oauth_consumer" referenceColumn="entity_id"
  121. onDelete="CASCADE"/>
  122. <constraint xsi:type="unique" referenceId="INTEGRATION_NAME">
  123. <column name="name"/>
  124. </constraint>
  125. <constraint xsi:type="unique" referenceId="INTEGRATION_CONSUMER_ID">
  126. <column name="consumer_id"/>
  127. </constraint>
  128. </table>
  129. <table name="oauth_token_request_log" resource="default" engine="innodb"
  130. comment="Log of token request authentication failures.">
  131. <column xsi:type="int" name="log_id" padding="10" unsigned="true" nullable="false" identity="true"
  132. comment="Log Id"/>
  133. <column xsi:type="varchar" name="user_name" nullable="false" length="255"
  134. comment="Customer email or admin login"/>
  135. <column xsi:type="smallint" name="user_type" padding="5" unsigned="true" nullable="false" identity="false"
  136. comment="User type (admin or customer)"/>
  137. <column xsi:type="smallint" name="failures_count" padding="5" unsigned="true" nullable="true" identity="false"
  138. default="0" comment="Number of failed authentication attempts in a row"/>
  139. <column xsi:type="timestamp" name="lock_expires_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
  140. comment="Lock expiration time"/>
  141. <constraint xsi:type="primary" referenceId="PRIMARY">
  142. <column name="log_id"/>
  143. </constraint>
  144. <constraint xsi:type="unique" referenceId="OAUTH_TOKEN_REQUEST_LOG_USER_NAME_USER_TYPE">
  145. <column name="user_name"/>
  146. <column name="user_type"/>
  147. </constraint>
  148. </table>
  149. </schema>