@csbeker/medusa-product-attributes 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/.medusa/server/src/admin/index.js +9012 -0
  2. package/.medusa/server/src/admin/index.mjs +9010 -0
  3. package/.medusa/server/src/api/admin/middlewares.js +10 -0
  4. package/.medusa/server/src/api/admin/plugin/attribute-set/[id]/attributes/route.js +17 -0
  5. package/.medusa/server/src/api/admin/plugin/attribute-set/[id]/route.js +33 -0
  6. package/.medusa/server/src/api/admin/plugin/attribute-set/middlewares.js +44 -0
  7. package/.medusa/server/src/api/admin/plugin/attribute-set/query-config.js +22 -0
  8. package/.medusa/server/src/api/admin/plugin/attribute-set/route.js +25 -0
  9. package/.medusa/server/src/api/admin/plugin/attribute-set/validators.js +37 -0
  10. package/.medusa/server/src/api/admin/plugin/attributes/[id]/route.js +68 -0
  11. package/.medusa/server/src/api/admin/plugin/attributes/[id]/values/[valueId]/route.js +37 -0
  12. package/.medusa/server/src/api/admin/plugin/attributes/[id]/values/route.js +31 -0
  13. package/.medusa/server/src/api/admin/plugin/attributes/middlewares.js +103 -0
  14. package/.medusa/server/src/api/admin/plugin/attributes/query-config.js +41 -0
  15. package/.medusa/server/src/api/admin/plugin/attributes/route.js +28 -0
  16. package/.medusa/server/src/api/admin/plugin/attributes/validators.js +69 -0
  17. package/.medusa/server/src/api/admin/plugin/route.js +7 -0
  18. package/.medusa/server/src/api/middlewares.js +12 -0
  19. package/.medusa/server/src/api/store/middlewares.js +8 -0
  20. package/.medusa/server/src/api/store/plugin/attributes/middlewares.js +64 -0
  21. package/.medusa/server/src/api/store/plugin/attributes/products/middlewares.js +100 -0
  22. package/.medusa/server/src/api/store/plugin/attributes/products/query-config.js +20 -0
  23. package/.medusa/server/src/api/store/plugin/attributes/products/route.js +48 -0
  24. package/.medusa/server/src/api/store/plugin/attributes/products/validators.js +39 -0
  25. package/.medusa/server/src/api/store/plugin/attributes/query-config.js +21 -0
  26. package/.medusa/server/src/api/store/plugin/attributes/route.js +15 -0
  27. package/.medusa/server/src/api/store/plugin/attributes/validators.js +14 -0
  28. package/.medusa/server/src/api/store/plugin/route.js +7 -0
  29. package/.medusa/server/src/api/utils/common-validators.js +23 -0
  30. package/.medusa/server/src/api/utils/constants.js +6 -0
  31. package/.medusa/server/src/api/utils/middlewares.js +34 -0
  32. package/.medusa/server/src/links/attribute-product-category.js +16 -0
  33. package/.medusa/server/src/links/attribute-value-product.js +16 -0
  34. package/.medusa/server/src/modules/attribute/events/index.js +8 -0
  35. package/.medusa/server/src/modules/attribute/index.js +13 -0
  36. package/.medusa/server/src/modules/attribute/migrations/Migration20250319161229.js +24 -0
  37. package/.medusa/server/src/modules/attribute/migrations/Migration20250320182643.js +16 -0
  38. package/.medusa/server/src/modules/attribute/migrations/Migration20250321162638.js +14 -0
  39. package/.medusa/server/src/modules/attribute/migrations/Migration20250505144933.js +23 -0
  40. package/.medusa/server/src/modules/attribute/migrations/Migration20250505201747.js +21 -0
  41. package/.medusa/server/src/modules/attribute/migrations/Migration20250506162300.js +14 -0
  42. package/.medusa/server/src/modules/attribute/migrations/Migration20250611160552.js +14 -0
  43. package/.medusa/server/src/modules/attribute/migrations/Migration20250611173345.js +16 -0
  44. package/.medusa/server/src/modules/attribute/migrations/Migration20250612192857.js +16 -0
  45. package/.medusa/server/src/modules/attribute/models/attribute-possible-value.js +24 -0
  46. package/.medusa/server/src/modules/attribute/models/attribute-set.js +22 -0
  47. package/.medusa/server/src/modules/attribute/models/attribute-value.js +17 -0
  48. package/.medusa/server/src/modules/attribute/models/attribute.js +27 -0
  49. package/.medusa/server/src/modules/attribute/service.js +84 -0
  50. package/.medusa/server/src/modules/attribute/types/attribute/common.js +13 -0
  51. package/.medusa/server/src/modules/attribute/types/attribute/index.js +18 -0
  52. package/.medusa/server/src/modules/attribute/types/attribute-set/index.js +18 -0
  53. package/.medusa/server/src/modules/attribute/types/attribute-set/mutations.js +3 -0
  54. package/.medusa/server/src/modules/attribute/types/attribute-value/index.js +18 -0
  55. package/.medusa/server/src/modules/attribute/types/attribute-value/mutations.js +3 -0
  56. package/.medusa/server/src/modules/attribute/types/index.js +20 -0
  57. package/.medusa/server/src/types/attribute/common.js +3 -0
  58. package/.medusa/server/src/types/attribute/http/attribute/admin/index.js +3 -0
  59. package/.medusa/server/src/types/attribute/http/attribute/index.js +18 -0
  60. package/.medusa/server/src/types/attribute/http/attribute-set/index.js +3 -0
  61. package/.medusa/server/src/types/attribute/http/index.js +19 -0
  62. package/.medusa/server/src/types/attribute/index.js +19 -0
  63. package/.medusa/server/src/utils/index.js +18 -0
  64. package/.medusa/server/src/utils/products-created-handler.js +22 -0
  65. package/.medusa/server/src/utils/products-updated-handler.js +58 -0
  66. package/.medusa/server/src/utils/validate-attribute-values-to-link.js +43 -0
  67. package/.medusa/server/src/workflows/attribute/index.js +19 -0
  68. package/.medusa/server/src/workflows/attribute/steps/create-attribute-possible-values.js +18 -0
  69. package/.medusa/server/src/workflows/attribute/steps/create-attributes.js +27 -0
  70. package/.medusa/server/src/workflows/attribute/steps/delete-attribute.js +31 -0
  71. package/.medusa/server/src/workflows/attribute/steps/index.js +21 -0
  72. package/.medusa/server/src/workflows/attribute/steps/update-attributes.js +34 -0
  73. package/.medusa/server/src/workflows/attribute/workflows/create-attribute-possible-values.js +11 -0
  74. package/.medusa/server/src/workflows/attribute/workflows/create-attributes.js +46 -0
  75. package/.medusa/server/src/workflows/attribute/workflows/delete-attribute.js +10 -0
  76. package/.medusa/server/src/workflows/attribute/workflows/index.js +20 -0
  77. package/.medusa/server/src/workflows/attribute/workflows/update-attributes.js +73 -0
  78. package/.medusa/server/src/workflows/attribute-set/steps/batch-link-attribute-set-attributes.js +66 -0
  79. package/.medusa/server/src/workflows/attribute-set/steps/create-attribute-set.js +24 -0
  80. package/.medusa/server/src/workflows/attribute-set/steps/index.js +20 -0
  81. package/.medusa/server/src/workflows/attribute-set/steps/update-attribute-set.js +22 -0
  82. package/.medusa/server/src/workflows/attribute-set/workflows/batch-link-attribute-set-attributes.js +10 -0
  83. package/.medusa/server/src/workflows/attribute-set/workflows/create-attribute-set.js +11 -0
  84. package/.medusa/server/src/workflows/attribute-set/workflows/index.js +20 -0
  85. package/.medusa/server/src/workflows/attribute-set/workflows/update-attribute-set.js +10 -0
  86. package/.medusa/server/src/workflows/attribute-value/steps/create-attribute-value.js +18 -0
  87. package/.medusa/server/src/workflows/attribute-value/steps/delete-attribute-value.js +18 -0
  88. package/.medusa/server/src/workflows/attribute-value/steps/index.js +20 -0
  89. package/.medusa/server/src/workflows/attribute-value/steps/validate-attribute-value.js +53 -0
  90. package/.medusa/server/src/workflows/attribute-value/workflow/create-attribute-value.js +28 -0
  91. package/.medusa/server/src/workflows/attribute-value/workflow/delete-attribute-value.js +38 -0
  92. package/.medusa/server/src/workflows/attribute-value/workflow/index.js +19 -0
  93. package/.medusa/server/src/workflows/attribute_possible_value/index.js +19 -0
  94. package/.medusa/server/src/workflows/attribute_possible_value/steps/index.js +18 -0
  95. package/.medusa/server/src/workflows/attribute_possible_value/steps/update-attribute-possible-value.js +18 -0
  96. package/.medusa/server/src/workflows/attribute_possible_value/workflows/index.js +18 -0
  97. package/.medusa/server/src/workflows/attribute_possible_value/workflows/update-attribute-possible-value.js +11 -0
  98. package/.medusa/server/src/workflows/index.js +18 -0
  99. package/CHANGELOG.md +104 -0
  100. package/README.md +86 -0
  101. package/package.json +90 -0
  102. package/src/admin/README.md +31 -0
  103. package/src/admin/components/metadata-editor/index.tsx +101 -0
  104. package/src/admin/components/section-row.tsx +41 -0
  105. package/src/admin/hooks/api/attribute-set.ts +122 -0
  106. package/src/admin/hooks/api/attributes.ts +126 -0
  107. package/src/admin/hooks/table/columns/index.ts +1 -0
  108. package/src/admin/hooks/table/columns/use-attribute-table-columns.tsx +280 -0
  109. package/src/admin/layouts/single-column.tsx +11 -0
  110. package/src/admin/lib/config.ts +8 -0
  111. package/src/admin/lib/query-key-factory.ts +53 -0
  112. package/src/admin/routes/attributes/[id]/edit/page.tsx +133 -0
  113. package/src/admin/routes/attributes/[id]/edit-possible-value/page.tsx +174 -0
  114. package/src/admin/routes/attributes/[id]/page.tsx +127 -0
  115. package/src/admin/routes/attributes/components/AttributeForm.tsx +301 -0
  116. package/src/admin/routes/attributes/components/AttributeSetTable.tsx +108 -0
  117. package/src/admin/routes/attributes/components/category-selection-modal.tsx +82 -0
  118. package/src/admin/routes/attributes/components/possible-values-table.tsx +119 -0
  119. package/src/admin/routes/attributes/create/components/MultiSelectCategory.tsx +148 -0
  120. package/src/admin/routes/attributes/create/components/PossibleValuesList.tsx +151 -0
  121. package/src/admin/routes/attributes/create/page.tsx +123 -0
  122. package/src/admin/routes/attributes/create-set/page.tsx +110 -0
  123. package/src/admin/routes/attributes/page.tsx +346 -0
  124. package/src/admin/routes/attributes/set/[id]/attributes/page.tsx +35 -0
  125. package/src/admin/routes/attributes/set/[id]/components/AttributeSetAttributesSection.tsx +114 -0
  126. package/src/admin/routes/attributes/set/[id]/components/AttributeSetGeneralSection.tsx +42 -0
  127. package/src/admin/routes/attributes/set/[id]/components/attribute-set-attributes-form.tsx +143 -0
  128. package/src/admin/routes/attributes/set/[id]/components/index.ts +2 -0
  129. package/src/admin/routes/attributes/set/[id]/edit/page.tsx +119 -0
  130. package/src/admin/routes/attributes/set/[id]/page.tsx +45 -0
  131. package/src/admin/tsconfig.json +27 -0
  132. package/src/admin/types/global.d.ts +3 -0
  133. package/src/admin/vite-env.d.ts +1 -0
  134. package/src/api/README.md +133 -0
  135. package/src/api/admin/middlewares.ts +8 -0
  136. package/src/api/admin/plugin/attribute-set/[id]/attributes/route.ts +17 -0
  137. package/src/api/admin/plugin/attribute-set/[id]/route.ts +41 -0
  138. package/src/api/admin/plugin/attribute-set/middlewares.ts +42 -0
  139. package/src/api/admin/plugin/attribute-set/query-config.ts +20 -0
  140. package/src/api/admin/plugin/attribute-set/route.ts +34 -0
  141. package/src/api/admin/plugin/attribute-set/validators.ts +45 -0
  142. package/src/api/admin/plugin/attributes/[id]/route.ts +85 -0
  143. package/src/api/admin/plugin/attributes/[id]/values/[valueId]/route.ts +41 -0
  144. package/src/api/admin/plugin/attributes/[id]/values/route.ts +39 -0
  145. package/src/api/admin/plugin/attributes/middlewares.ts +91 -0
  146. package/src/api/admin/plugin/attributes/query-config.ts +42 -0
  147. package/src/api/admin/plugin/attributes/route.ts +33 -0
  148. package/src/api/admin/plugin/attributes/validators.ts +91 -0
  149. package/src/api/admin/plugin/route.ts +8 -0
  150. package/src/api/middlewares.ts +10 -0
  151. package/src/api/store/middlewares.ts +6 -0
  152. package/src/api/store/plugin/attributes/middlewares.ts +33 -0
  153. package/src/api/store/plugin/attributes/products/middlewares.ts +73 -0
  154. package/src/api/store/plugin/attributes/products/query-config.ts +19 -0
  155. package/src/api/store/plugin/attributes/products/route.ts +68 -0
  156. package/src/api/store/plugin/attributes/products/validators.ts +55 -0
  157. package/src/api/store/plugin/attributes/query-config.ts +19 -0
  158. package/src/api/store/plugin/attributes/route.ts +13 -0
  159. package/src/api/store/plugin/attributes/validators.ts +14 -0
  160. package/src/api/store/plugin/route.ts +8 -0
  161. package/src/api/utils/common-validators.ts +24 -0
  162. package/src/api/utils/constants.ts +2 -0
  163. package/src/api/utils/middlewares.ts +31 -0
  164. package/src/jobs/README.md +36 -0
  165. package/src/links/README.md +26 -0
  166. package/src/links/attribute-product-category.ts +14 -0
  167. package/src/links/attribute-value-product.ts +14 -0
  168. package/src/modules/README.md +116 -0
  169. package/src/modules/attribute/events/index.ts +4 -0
  170. package/src/modules/attribute/index.ts +8 -0
  171. package/src/modules/attribute/migrations/.snapshot-medusa-attribute.json +624 -0
  172. package/src/modules/attribute/migrations/Migration20250319161229.ts +27 -0
  173. package/src/modules/attribute/migrations/Migration20250320182643.ts +15 -0
  174. package/src/modules/attribute/migrations/Migration20250321162638.ts +13 -0
  175. package/src/modules/attribute/migrations/Migration20250505144933.ts +26 -0
  176. package/src/modules/attribute/migrations/Migration20250505201747.ts +23 -0
  177. package/src/modules/attribute/migrations/Migration20250506162300.ts +13 -0
  178. package/src/modules/attribute/migrations/Migration20250611160552.ts +13 -0
  179. package/src/modules/attribute/migrations/Migration20250611173345.ts +17 -0
  180. package/src/modules/attribute/migrations/Migration20250612192857.ts +17 -0
  181. package/src/modules/attribute/models/attribute-possible-value.ts +20 -0
  182. package/src/modules/attribute/models/attribute-set.ts +18 -0
  183. package/src/modules/attribute/models/attribute-value.ts +13 -0
  184. package/src/modules/attribute/models/attribute.ts +23 -0
  185. package/src/modules/attribute/service.ts +102 -0
  186. package/src/modules/attribute/types/attribute/common.ts +94 -0
  187. package/src/modules/attribute/types/attribute/index.ts +1 -0
  188. package/src/modules/attribute/types/attribute-set/index.ts +1 -0
  189. package/src/modules/attribute/types/attribute-set/mutations.ts +7 -0
  190. package/src/modules/attribute/types/attribute-value/index.ts +1 -0
  191. package/src/modules/attribute/types/attribute-value/mutations.ts +5 -0
  192. package/src/modules/attribute/types/index.ts +3 -0
  193. package/src/providers/README.md +30 -0
  194. package/src/subscribers/README.md +59 -0
  195. package/src/types/attribute/common.ts +173 -0
  196. package/src/types/attribute/http/attribute/admin/index.ts +0 -0
  197. package/src/types/attribute/http/attribute/index.ts +42 -0
  198. package/src/types/attribute/http/attribute-set/index.ts +10 -0
  199. package/src/types/attribute/http/index.ts +2 -0
  200. package/src/types/attribute/index.ts +2 -0
  201. package/src/utils/index.ts +1 -0
  202. package/src/utils/products-created-handler.ts +35 -0
  203. package/src/utils/products-updated-handler.ts +74 -0
  204. package/src/utils/validate-attribute-values-to-link.ts +67 -0
  205. package/src/workflows/README.md +79 -0
  206. package/src/workflows/attribute/index.ts +2 -0
  207. package/src/workflows/attribute/steps/create-attribute-possible-values.ts +29 -0
  208. package/src/workflows/attribute/steps/create-attributes.ts +35 -0
  209. package/src/workflows/attribute/steps/delete-attribute.ts +41 -0
  210. package/src/workflows/attribute/steps/index.ts +4 -0
  211. package/src/workflows/attribute/steps/update-attributes.ts +45 -0
  212. package/src/workflows/attribute/workflows/create-attribute-possible-values.ts +17 -0
  213. package/src/workflows/attribute/workflows/create-attributes.ts +56 -0
  214. package/src/workflows/attribute/workflows/delete-attribute.ts +15 -0
  215. package/src/workflows/attribute/workflows/index.ts +3 -0
  216. package/src/workflows/attribute/workflows/update-attributes.ts +103 -0
  217. package/src/workflows/attribute-set/steps/batch-link-attribute-set-attributes.ts +82 -0
  218. package/src/workflows/attribute-set/steps/create-attribute-set.ts +34 -0
  219. package/src/workflows/attribute-set/steps/index.ts +3 -0
  220. package/src/workflows/attribute-set/steps/update-attribute-set.ts +32 -0
  221. package/src/workflows/attribute-set/workflows/batch-link-attribute-set-attributes.ts +12 -0
  222. package/src/workflows/attribute-set/workflows/create-attribute-set.ts +17 -0
  223. package/src/workflows/attribute-set/workflows/index.ts +3 -0
  224. package/src/workflows/attribute-set/workflows/update-attribute-set.ts +14 -0
  225. package/src/workflows/attribute-value/steps/create-attribute-value.ts +26 -0
  226. package/src/workflows/attribute-value/steps/delete-attribute-value.ts +26 -0
  227. package/src/workflows/attribute-value/steps/index.ts +3 -0
  228. package/src/workflows/attribute-value/steps/validate-attribute-value.ts +95 -0
  229. package/src/workflows/attribute-value/workflow/create-attribute-value.ts +36 -0
  230. package/src/workflows/attribute-value/workflow/delete-attribute-value.ts +46 -0
  231. package/src/workflows/attribute-value/workflow/index.ts +2 -0
  232. package/src/workflows/attribute_possible_value/index.ts +2 -0
  233. package/src/workflows/attribute_possible_value/steps/index.ts +1 -0
  234. package/src/workflows/attribute_possible_value/steps/update-attribute-possible-value.ts +25 -0
  235. package/src/workflows/attribute_possible_value/workflows/index.ts +1 -0
  236. package/src/workflows/attribute_possible_value/workflows/update-attribute-possible-value.ts +15 -0
  237. package/src/workflows/index.ts +1 -0
@@ -0,0 +1,624 @@
1
+ {
2
+ "namespaces": [
3
+ "public"
4
+ ],
5
+ "name": "public",
6
+ "tables": [
7
+ {
8
+ "columns": {
9
+ "id": {
10
+ "name": "id",
11
+ "type": "text",
12
+ "unsigned": false,
13
+ "autoincrement": false,
14
+ "primary": false,
15
+ "nullable": false,
16
+ "mappedType": "text"
17
+ },
18
+ "name": {
19
+ "name": "name",
20
+ "type": "text",
21
+ "unsigned": false,
22
+ "autoincrement": false,
23
+ "primary": false,
24
+ "nullable": false,
25
+ "mappedType": "text"
26
+ },
27
+ "description": {
28
+ "name": "description",
29
+ "type": "text",
30
+ "unsigned": false,
31
+ "autoincrement": false,
32
+ "primary": false,
33
+ "nullable": true,
34
+ "mappedType": "text"
35
+ },
36
+ "is_variant_defining": {
37
+ "name": "is_variant_defining",
38
+ "type": "boolean",
39
+ "unsigned": false,
40
+ "autoincrement": false,
41
+ "primary": false,
42
+ "nullable": false,
43
+ "default": "true",
44
+ "mappedType": "boolean"
45
+ },
46
+ "is_filterable": {
47
+ "name": "is_filterable",
48
+ "type": "boolean",
49
+ "unsigned": false,
50
+ "autoincrement": false,
51
+ "primary": false,
52
+ "nullable": false,
53
+ "default": "true",
54
+ "mappedType": "boolean"
55
+ },
56
+ "handle": {
57
+ "name": "handle",
58
+ "type": "text",
59
+ "unsigned": false,
60
+ "autoincrement": false,
61
+ "primary": false,
62
+ "nullable": false,
63
+ "mappedType": "text"
64
+ },
65
+ "ui_component": {
66
+ "name": "ui_component",
67
+ "type": "text",
68
+ "unsigned": false,
69
+ "autoincrement": false,
70
+ "primary": false,
71
+ "nullable": false,
72
+ "default": "'select'",
73
+ "enumItems": [
74
+ "select",
75
+ "multivalue",
76
+ "unit",
77
+ "toggle",
78
+ "text_area",
79
+ "color_picker"
80
+ ],
81
+ "mappedType": "enum"
82
+ },
83
+ "metadata": {
84
+ "name": "metadata",
85
+ "type": "jsonb",
86
+ "unsigned": false,
87
+ "autoincrement": false,
88
+ "primary": false,
89
+ "nullable": true,
90
+ "mappedType": "json"
91
+ },
92
+ "created_at": {
93
+ "name": "created_at",
94
+ "type": "timestamptz",
95
+ "unsigned": false,
96
+ "autoincrement": false,
97
+ "primary": false,
98
+ "nullable": false,
99
+ "length": 6,
100
+ "default": "now()",
101
+ "mappedType": "datetime"
102
+ },
103
+ "updated_at": {
104
+ "name": "updated_at",
105
+ "type": "timestamptz",
106
+ "unsigned": false,
107
+ "autoincrement": false,
108
+ "primary": false,
109
+ "nullable": false,
110
+ "length": 6,
111
+ "default": "now()",
112
+ "mappedType": "datetime"
113
+ },
114
+ "deleted_at": {
115
+ "name": "deleted_at",
116
+ "type": "timestamptz",
117
+ "unsigned": false,
118
+ "autoincrement": false,
119
+ "primary": false,
120
+ "nullable": true,
121
+ "length": 6,
122
+ "mappedType": "datetime"
123
+ }
124
+ },
125
+ "name": "attribute",
126
+ "schema": "public",
127
+ "indexes": [
128
+ {
129
+ "keyName": "IDX_ATTRIBUTE_NAME",
130
+ "columnNames": [],
131
+ "composite": false,
132
+ "constraint": false,
133
+ "primary": false,
134
+ "unique": false,
135
+ "expression": "CREATE INDEX IF NOT EXISTS \"IDX_ATTRIBUTE_NAME\" ON \"attribute\" (name) WHERE deleted_at IS NULL"
136
+ },
137
+ {
138
+ "keyName": "IDX_attribute_handle_unique",
139
+ "columnNames": [],
140
+ "composite": false,
141
+ "constraint": false,
142
+ "primary": false,
143
+ "unique": false,
144
+ "expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_attribute_handle_unique\" ON \"attribute\" (handle) WHERE deleted_at IS NULL"
145
+ },
146
+ {
147
+ "keyName": "IDX_attribute_deleted_at",
148
+ "columnNames": [],
149
+ "composite": false,
150
+ "constraint": false,
151
+ "primary": false,
152
+ "unique": false,
153
+ "expression": "CREATE INDEX IF NOT EXISTS \"IDX_attribute_deleted_at\" ON \"attribute\" (deleted_at) WHERE deleted_at IS NULL"
154
+ },
155
+ {
156
+ "keyName": "attribute_pkey",
157
+ "columnNames": [
158
+ "id"
159
+ ],
160
+ "composite": false,
161
+ "constraint": true,
162
+ "primary": true,
163
+ "unique": true
164
+ }
165
+ ],
166
+ "checks": [],
167
+ "foreignKeys": {},
168
+ "nativeEnums": {}
169
+ },
170
+ {
171
+ "columns": {
172
+ "id": {
173
+ "name": "id",
174
+ "type": "text",
175
+ "unsigned": false,
176
+ "autoincrement": false,
177
+ "primary": false,
178
+ "nullable": false,
179
+ "mappedType": "text"
180
+ },
181
+ "value": {
182
+ "name": "value",
183
+ "type": "text",
184
+ "unsigned": false,
185
+ "autoincrement": false,
186
+ "primary": false,
187
+ "nullable": false,
188
+ "mappedType": "text"
189
+ },
190
+ "rank": {
191
+ "name": "rank",
192
+ "type": "integer",
193
+ "unsigned": false,
194
+ "autoincrement": false,
195
+ "primary": false,
196
+ "nullable": false,
197
+ "mappedType": "integer"
198
+ },
199
+ "metadata": {
200
+ "name": "metadata",
201
+ "type": "jsonb",
202
+ "unsigned": false,
203
+ "autoincrement": false,
204
+ "primary": false,
205
+ "nullable": true,
206
+ "mappedType": "json"
207
+ },
208
+ "attribute_id": {
209
+ "name": "attribute_id",
210
+ "type": "text",
211
+ "unsigned": false,
212
+ "autoincrement": false,
213
+ "primary": false,
214
+ "nullable": false,
215
+ "mappedType": "text"
216
+ },
217
+ "created_at": {
218
+ "name": "created_at",
219
+ "type": "timestamptz",
220
+ "unsigned": false,
221
+ "autoincrement": false,
222
+ "primary": false,
223
+ "nullable": false,
224
+ "length": 6,
225
+ "default": "now()",
226
+ "mappedType": "datetime"
227
+ },
228
+ "updated_at": {
229
+ "name": "updated_at",
230
+ "type": "timestamptz",
231
+ "unsigned": false,
232
+ "autoincrement": false,
233
+ "primary": false,
234
+ "nullable": false,
235
+ "length": 6,
236
+ "default": "now()",
237
+ "mappedType": "datetime"
238
+ },
239
+ "deleted_at": {
240
+ "name": "deleted_at",
241
+ "type": "timestamptz",
242
+ "unsigned": false,
243
+ "autoincrement": false,
244
+ "primary": false,
245
+ "nullable": true,
246
+ "length": 6,
247
+ "mappedType": "datetime"
248
+ }
249
+ },
250
+ "name": "attribute_possible_value",
251
+ "schema": "public",
252
+ "indexes": [
253
+ {
254
+ "keyName": "IDX_attribute_possible_value_attribute_id",
255
+ "columnNames": [],
256
+ "composite": false,
257
+ "constraint": false,
258
+ "primary": false,
259
+ "unique": false,
260
+ "expression": "CREATE INDEX IF NOT EXISTS \"IDX_attribute_possible_value_attribute_id\" ON \"attribute_possible_value\" (attribute_id) WHERE deleted_at IS NULL"
261
+ },
262
+ {
263
+ "keyName": "IDX_attribute_possible_value_deleted_at",
264
+ "columnNames": [],
265
+ "composite": false,
266
+ "constraint": false,
267
+ "primary": false,
268
+ "unique": false,
269
+ "expression": "CREATE INDEX IF NOT EXISTS \"IDX_attribute_possible_value_deleted_at\" ON \"attribute_possible_value\" (deleted_at) WHERE deleted_at IS NULL"
270
+ },
271
+ {
272
+ "keyName": "UQ_attribute_id_value",
273
+ "columnNames": [],
274
+ "composite": false,
275
+ "constraint": false,
276
+ "primary": false,
277
+ "unique": false,
278
+ "expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"UQ_attribute_id_value\" ON \"attribute_possible_value\" (attribute_id, value) WHERE deleted_at IS NULL"
279
+ },
280
+ {
281
+ "keyName": "attribute_possible_value_pkey",
282
+ "columnNames": [
283
+ "id"
284
+ ],
285
+ "composite": false,
286
+ "constraint": true,
287
+ "primary": true,
288
+ "unique": true
289
+ }
290
+ ],
291
+ "checks": [],
292
+ "foreignKeys": {
293
+ "attribute_possible_value_attribute_id_foreign": {
294
+ "constraintName": "attribute_possible_value_attribute_id_foreign",
295
+ "columnNames": [
296
+ "attribute_id"
297
+ ],
298
+ "localTableName": "public.attribute_possible_value",
299
+ "referencedColumnNames": [
300
+ "id"
301
+ ],
302
+ "referencedTableName": "public.attribute",
303
+ "deleteRule": "cascade",
304
+ "updateRule": "cascade"
305
+ }
306
+ },
307
+ "nativeEnums": {}
308
+ },
309
+ {
310
+ "columns": {
311
+ "id": {
312
+ "name": "id",
313
+ "type": "text",
314
+ "unsigned": false,
315
+ "autoincrement": false,
316
+ "primary": false,
317
+ "nullable": false,
318
+ "mappedType": "text"
319
+ },
320
+ "name": {
321
+ "name": "name",
322
+ "type": "text",
323
+ "unsigned": false,
324
+ "autoincrement": false,
325
+ "primary": false,
326
+ "nullable": false,
327
+ "mappedType": "text"
328
+ },
329
+ "description": {
330
+ "name": "description",
331
+ "type": "text",
332
+ "unsigned": false,
333
+ "autoincrement": false,
334
+ "primary": false,
335
+ "nullable": true,
336
+ "mappedType": "text"
337
+ },
338
+ "handle": {
339
+ "name": "handle",
340
+ "type": "text",
341
+ "unsigned": false,
342
+ "autoincrement": false,
343
+ "primary": false,
344
+ "nullable": false,
345
+ "mappedType": "text"
346
+ },
347
+ "metadata": {
348
+ "name": "metadata",
349
+ "type": "jsonb",
350
+ "unsigned": false,
351
+ "autoincrement": false,
352
+ "primary": false,
353
+ "nullable": true,
354
+ "mappedType": "json"
355
+ },
356
+ "created_at": {
357
+ "name": "created_at",
358
+ "type": "timestamptz",
359
+ "unsigned": false,
360
+ "autoincrement": false,
361
+ "primary": false,
362
+ "nullable": false,
363
+ "length": 6,
364
+ "default": "now()",
365
+ "mappedType": "datetime"
366
+ },
367
+ "updated_at": {
368
+ "name": "updated_at",
369
+ "type": "timestamptz",
370
+ "unsigned": false,
371
+ "autoincrement": false,
372
+ "primary": false,
373
+ "nullable": false,
374
+ "length": 6,
375
+ "default": "now()",
376
+ "mappedType": "datetime"
377
+ },
378
+ "deleted_at": {
379
+ "name": "deleted_at",
380
+ "type": "timestamptz",
381
+ "unsigned": false,
382
+ "autoincrement": false,
383
+ "primary": false,
384
+ "nullable": true,
385
+ "length": 6,
386
+ "mappedType": "datetime"
387
+ }
388
+ },
389
+ "name": "attribute_set",
390
+ "schema": "public",
391
+ "indexes": [
392
+ {
393
+ "keyName": "IDX_ATTRIBUTE_SET_NAME",
394
+ "columnNames": [],
395
+ "composite": false,
396
+ "constraint": false,
397
+ "primary": false,
398
+ "unique": false,
399
+ "expression": "CREATE INDEX IF NOT EXISTS \"IDX_ATTRIBUTE_SET_NAME\" ON \"attribute_set\" (name) WHERE deleted_at IS NULL"
400
+ },
401
+ {
402
+ "keyName": "IDX_attribute_set_handle_unique",
403
+ "columnNames": [],
404
+ "composite": false,
405
+ "constraint": false,
406
+ "primary": false,
407
+ "unique": false,
408
+ "expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_attribute_set_handle_unique\" ON \"attribute_set\" (handle) WHERE deleted_at IS NULL"
409
+ },
410
+ {
411
+ "keyName": "IDX_attribute_set_deleted_at",
412
+ "columnNames": [],
413
+ "composite": false,
414
+ "constraint": false,
415
+ "primary": false,
416
+ "unique": false,
417
+ "expression": "CREATE INDEX IF NOT EXISTS \"IDX_attribute_set_deleted_at\" ON \"attribute_set\" (deleted_at) WHERE deleted_at IS NULL"
418
+ },
419
+ {
420
+ "keyName": "attribute_set_pkey",
421
+ "columnNames": [
422
+ "id"
423
+ ],
424
+ "composite": false,
425
+ "constraint": true,
426
+ "primary": true,
427
+ "unique": true
428
+ }
429
+ ],
430
+ "checks": [],
431
+ "foreignKeys": {},
432
+ "nativeEnums": {}
433
+ },
434
+ {
435
+ "columns": {
436
+ "attribute_set_id": {
437
+ "name": "attribute_set_id",
438
+ "type": "text",
439
+ "unsigned": false,
440
+ "autoincrement": false,
441
+ "primary": false,
442
+ "nullable": false,
443
+ "mappedType": "text"
444
+ },
445
+ "attribute_id": {
446
+ "name": "attribute_id",
447
+ "type": "text",
448
+ "unsigned": false,
449
+ "autoincrement": false,
450
+ "primary": false,
451
+ "nullable": false,
452
+ "mappedType": "text"
453
+ }
454
+ },
455
+ "name": "attribute_set_attributes",
456
+ "schema": "public",
457
+ "indexes": [
458
+ {
459
+ "keyName": "attribute_set_attributes_pkey",
460
+ "columnNames": [
461
+ "attribute_set_id",
462
+ "attribute_id"
463
+ ],
464
+ "composite": true,
465
+ "constraint": true,
466
+ "primary": true,
467
+ "unique": true
468
+ }
469
+ ],
470
+ "checks": [],
471
+ "foreignKeys": {
472
+ "attribute_set_attributes_attribute_set_id_foreign": {
473
+ "constraintName": "attribute_set_attributes_attribute_set_id_foreign",
474
+ "columnNames": [
475
+ "attribute_set_id"
476
+ ],
477
+ "localTableName": "public.attribute_set_attributes",
478
+ "referencedColumnNames": [
479
+ "id"
480
+ ],
481
+ "referencedTableName": "public.attribute_set",
482
+ "deleteRule": "cascade",
483
+ "updateRule": "cascade"
484
+ },
485
+ "attribute_set_attributes_attribute_id_foreign": {
486
+ "constraintName": "attribute_set_attributes_attribute_id_foreign",
487
+ "columnNames": [
488
+ "attribute_id"
489
+ ],
490
+ "localTableName": "public.attribute_set_attributes",
491
+ "referencedColumnNames": [
492
+ "id"
493
+ ],
494
+ "referencedTableName": "public.attribute",
495
+ "deleteRule": "cascade",
496
+ "updateRule": "cascade"
497
+ }
498
+ },
499
+ "nativeEnums": {}
500
+ },
501
+ {
502
+ "columns": {
503
+ "id": {
504
+ "name": "id",
505
+ "type": "text",
506
+ "unsigned": false,
507
+ "autoincrement": false,
508
+ "primary": false,
509
+ "nullable": false,
510
+ "mappedType": "text"
511
+ },
512
+ "value": {
513
+ "name": "value",
514
+ "type": "text",
515
+ "unsigned": false,
516
+ "autoincrement": false,
517
+ "primary": false,
518
+ "nullable": false,
519
+ "mappedType": "text"
520
+ },
521
+ "metadata": {
522
+ "name": "metadata",
523
+ "type": "jsonb",
524
+ "unsigned": false,
525
+ "autoincrement": false,
526
+ "primary": false,
527
+ "nullable": true,
528
+ "mappedType": "json"
529
+ },
530
+ "attribute_id": {
531
+ "name": "attribute_id",
532
+ "type": "text",
533
+ "unsigned": false,
534
+ "autoincrement": false,
535
+ "primary": false,
536
+ "nullable": false,
537
+ "mappedType": "text"
538
+ },
539
+ "created_at": {
540
+ "name": "created_at",
541
+ "type": "timestamptz",
542
+ "unsigned": false,
543
+ "autoincrement": false,
544
+ "primary": false,
545
+ "nullable": false,
546
+ "length": 6,
547
+ "default": "now()",
548
+ "mappedType": "datetime"
549
+ },
550
+ "updated_at": {
551
+ "name": "updated_at",
552
+ "type": "timestamptz",
553
+ "unsigned": false,
554
+ "autoincrement": false,
555
+ "primary": false,
556
+ "nullable": false,
557
+ "length": 6,
558
+ "default": "now()",
559
+ "mappedType": "datetime"
560
+ },
561
+ "deleted_at": {
562
+ "name": "deleted_at",
563
+ "type": "timestamptz",
564
+ "unsigned": false,
565
+ "autoincrement": false,
566
+ "primary": false,
567
+ "nullable": true,
568
+ "length": 6,
569
+ "mappedType": "datetime"
570
+ }
571
+ },
572
+ "name": "attribute_value",
573
+ "schema": "public",
574
+ "indexes": [
575
+ {
576
+ "keyName": "IDX_attribute_value_attribute_id",
577
+ "columnNames": [],
578
+ "composite": false,
579
+ "constraint": false,
580
+ "primary": false,
581
+ "unique": false,
582
+ "expression": "CREATE INDEX IF NOT EXISTS \"IDX_attribute_value_attribute_id\" ON \"attribute_value\" (attribute_id) WHERE deleted_at IS NULL"
583
+ },
584
+ {
585
+ "keyName": "IDX_attribute_value_deleted_at",
586
+ "columnNames": [],
587
+ "composite": false,
588
+ "constraint": false,
589
+ "primary": false,
590
+ "unique": false,
591
+ "expression": "CREATE INDEX IF NOT EXISTS \"IDX_attribute_value_deleted_at\" ON \"attribute_value\" (deleted_at) WHERE deleted_at IS NULL"
592
+ },
593
+ {
594
+ "keyName": "attribute_value_pkey",
595
+ "columnNames": [
596
+ "id"
597
+ ],
598
+ "composite": false,
599
+ "constraint": true,
600
+ "primary": true,
601
+ "unique": true
602
+ }
603
+ ],
604
+ "checks": [],
605
+ "foreignKeys": {
606
+ "attribute_value_attribute_id_foreign": {
607
+ "constraintName": "attribute_value_attribute_id_foreign",
608
+ "columnNames": [
609
+ "attribute_id"
610
+ ],
611
+ "localTableName": "public.attribute_value",
612
+ "referencedColumnNames": [
613
+ "id"
614
+ ],
615
+ "referencedTableName": "public.attribute",
616
+ "deleteRule": "cascade",
617
+ "updateRule": "cascade"
618
+ }
619
+ },
620
+ "nativeEnums": {}
621
+ }
622
+ ],
623
+ "nativeEnums": {}
624
+ }
@@ -0,0 +1,27 @@
1
+ import { Migration } from '@mikro-orm/migrations';
2
+
3
+ export class Migration20250319161229 extends Migration {
4
+
5
+ override async up(): Promise<void> {
6
+ this.addSql(`alter table if exists "attribute" drop constraint if exists "attribute_handle_unique";`);
7
+ this.addSql(`create table if not exists "attribute" ("id" text not null, "name" text not null, "description" text null, "is_variant_defining" boolean not null default true, "is_filterable" boolean not null default true, "handle" text not null, "metadata" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "attribute_pkey" primary key ("id"));`);
8
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_ATTRIBUTE_NAME" ON "attribute" (name) WHERE deleted_at IS NULL;`);
9
+ this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_attribute_handle_unique" ON "attribute" (handle) WHERE deleted_at IS NULL;`);
10
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_attribute_deleted_at" ON "attribute" (deleted_at) WHERE deleted_at IS NULL;`);
11
+
12
+ this.addSql(`create table if not exists "attribute_value" ("id" text not null, "value" text not null, "rank" integer not null, "metadata" jsonb null, "attribute_id" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "attribute_value_pkey" primary key ("id"));`);
13
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_attribute_value_attribute_id" ON "attribute_value" (attribute_id) WHERE deleted_at IS NULL;`);
14
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_attribute_value_deleted_at" ON "attribute_value" (deleted_at) WHERE deleted_at IS NULL;`);
15
+
16
+ this.addSql(`alter table if exists "attribute_value" add constraint "attribute_value_attribute_id_foreign" foreign key ("attribute_id") references "attribute" ("id") on update cascade on delete cascade;`);
17
+ }
18
+
19
+ override async down(): Promise<void> {
20
+ this.addSql(`alter table if exists "attribute_value" drop constraint if exists "attribute_value_attribute_id_foreign";`);
21
+
22
+ this.addSql(`drop table if exists "attribute" cascade;`);
23
+
24
+ this.addSql(`drop table if exists "attribute_value" cascade;`);
25
+ }
26
+
27
+ }
@@ -0,0 +1,15 @@
1
+ import { Migration } from '@mikro-orm/migrations';
2
+
3
+ export class Migration20250320182643 extends Migration {
4
+
5
+ override async up(): Promise<void> {
6
+ this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "UQ_attribute_id_value" ON "attribute_value" (attribute_id, value) WHERE deleted_at IS NULL;`);
7
+ this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "UQ_attribute_id_rank" ON "attribute_value" (attribute_id, rank) WHERE deleted_at IS NULL;`);
8
+ }
9
+
10
+ override async down(): Promise<void> {
11
+ this.addSql(`drop index if exists "UQ_attribute_id_value";`);
12
+ this.addSql(`drop index if exists "UQ_attribute_id_rank";`);
13
+ }
14
+
15
+ }
@@ -0,0 +1,13 @@
1
+ import { Migration } from '@mikro-orm/migrations';
2
+
3
+ export class Migration20250321162638 extends Migration {
4
+
5
+ override async up(): Promise<void> {
6
+ this.addSql(`drop index if exists "UQ_attribute_id_rank";`);
7
+ }
8
+
9
+ override async down(): Promise<void> {
10
+ this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "UQ_attribute_id_rank" ON "attribute_value" (attribute_id, rank) WHERE deleted_at IS NULL;`);
11
+ }
12
+
13
+ }