appwrite-utils-cli 0.0.273 → 0.0.275

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 (77) hide show
  1. package/README.md +5 -39
  2. package/dist/init.d.ts +2 -0
  3. package/dist/init.js +57 -0
  4. package/dist/main.js +62 -100
  5. package/dist/migrations/afterImportActions.d.ts +1 -4
  6. package/dist/migrations/afterImportActions.js +1 -0
  7. package/dist/migrations/appwriteToX.d.ts +46 -46
  8. package/dist/migrations/appwriteToX.js +6 -2
  9. package/dist/migrations/attributes.d.ts +1 -1
  10. package/dist/migrations/attributes.js +98 -70
  11. package/dist/migrations/backup.d.ts +240 -240
  12. package/dist/migrations/backup.js +1 -1
  13. package/dist/migrations/collections.d.ts +1 -1
  14. package/dist/migrations/collections.js +5 -5
  15. package/dist/migrations/converters.d.ts +9 -127
  16. package/dist/migrations/converters.js +1 -504
  17. package/dist/migrations/dataLoader.d.ts +470 -453
  18. package/dist/migrations/dataLoader.js +19 -1
  19. package/dist/migrations/dbHelpers.d.ts +1 -1
  20. package/dist/migrations/dbHelpers.js +3 -0
  21. package/dist/migrations/importController.d.ts +1 -1
  22. package/dist/migrations/importController.js +4 -7
  23. package/dist/migrations/importDataActions.d.ts +4 -6
  24. package/dist/migrations/importDataActions.js +6 -4
  25. package/dist/migrations/indexes.d.ts +1 -1
  26. package/dist/migrations/indexes.js +1 -1
  27. package/dist/migrations/migrationHelper.d.ts +29 -29
  28. package/dist/migrations/migrationHelper.js +1 -1
  29. package/dist/migrations/openapi.d.ts +1 -1
  30. package/dist/migrations/openapi.js +4 -1
  31. package/dist/migrations/queue.d.ts +1 -1
  32. package/dist/migrations/relationships.d.ts +5 -5
  33. package/dist/migrations/relationships.js +3 -0
  34. package/dist/migrations/schemaStrings.d.ts +2 -2
  35. package/dist/migrations/schemaStrings.js +93 -8
  36. package/dist/migrations/setupDatabase.d.ts +1 -1
  37. package/dist/migrations/setupDatabase.js +1 -1
  38. package/dist/migrations/storage.d.ts +1 -1
  39. package/dist/migrations/users.d.ts +1 -1
  40. package/dist/schemas/authUser.d.ts +12 -10
  41. package/dist/types.d.ts +0 -5
  42. package/dist/types.js +0 -2
  43. package/dist/utils/helperFunctions.d.ts +2 -3
  44. package/dist/utils/loadConfigs.d.ts +13 -0
  45. package/dist/utils/loadConfigs.js +47 -0
  46. package/dist/utils/setupFiles.d.ts +1 -0
  47. package/dist/utils/setupFiles.js +98 -223
  48. package/dist/utilsController.d.ts +1 -3
  49. package/dist/utilsController.js +14 -18
  50. package/package.json +9 -2
  51. package/src/init.ts +64 -0
  52. package/src/main.ts +73 -98
  53. package/src/migrations/afterImportActions.ts +1 -5
  54. package/src/migrations/appwriteToX.ts +6 -2
  55. package/src/migrations/attributes.ts +198 -145
  56. package/src/migrations/backup.ts +1 -1
  57. package/src/migrations/collections.ts +6 -12
  58. package/src/migrations/converters.ts +1 -540
  59. package/src/migrations/dataLoader.ts +19 -2
  60. package/src/migrations/dbHelpers.ts +4 -1
  61. package/src/migrations/importController.ts +5 -15
  62. package/src/migrations/importDataActions.ts +10 -14
  63. package/src/migrations/indexes.ts +1 -1
  64. package/src/migrations/migrationHelper.ts +1 -1
  65. package/src/migrations/openapi.ts +4 -1
  66. package/src/migrations/queue.ts +1 -1
  67. package/src/migrations/relationships.ts +4 -1
  68. package/src/migrations/schemaStrings.ts +106 -9
  69. package/src/migrations/setupDatabase.ts +1 -1
  70. package/src/migrations/storage.ts +1 -1
  71. package/src/migrations/users.ts +1 -1
  72. package/src/types.ts +0 -5
  73. package/src/utils/helperFunctions.ts +2 -3
  74. package/src/utils/loadConfigs.ts +55 -0
  75. package/src/utils/setupFiles.ts +114 -225
  76. package/src/utilsController.ts +27 -35
  77. package/src/migrations/schema.ts +0 -748
@@ -1,49 +1,21 @@
1
1
  import { Query, type Databases, type Models } from "node-appwrite";
2
- import { parseAttribute, type Attribute } from "./schema.js";
2
+ import {
3
+ attributeSchema,
4
+ parseAttribute,
5
+ type Attribute,
6
+ } from "appwrite-utils";
3
7
  import { nameToIdMapping, enqueueOperation } from "./queue.js";
4
8
  import _ from "lodash";
5
9
 
6
- const attributesSame = (a: Attribute, b: Attribute) => {
7
- // Direct type comparison for non-string types
8
- // Also check if the type IS string and has a format for either
9
- // That means the format is the type of the attribute
10
- if (
11
- a.type === b.type &&
12
- !((a.type === "string" && a.format) || (b.type === "string" && b.format))
13
- ) {
14
- if (a.type === "relationship" && b.type === "relationship") {
15
- return (
16
- a.key === b.key &&
17
- a.relationType === b.relationType &&
18
- a.twoWay === b.twoWay &&
19
- a.twoWayKey === b.twoWayKey &&
20
- a.required === b.required
21
- );
22
- }
23
- return a.key === b.key && a.array === b.array && a.required === b.required;
24
- }
25
-
26
- if (a.type === "string" && a.format) {
27
- // @ts-expect-error
28
- a.type = a.format;
29
- }
30
- if (b.type === "string" && b.format) {
31
- // @ts-expect-error
32
- b.type = b.format;
33
- }
34
-
35
- // Handling string types with specific formats in Appwrite
36
- if (a.type === "string" && b.type === "string") {
37
- return (
38
- a.key === b.key &&
39
- a.format === b.format &&
40
- a.array === b.array &&
41
- a.required === b.required
42
- );
43
- }
44
-
45
- // Fallback to false if none of the above conditions are met
46
- return false;
10
+ const attributesSame = (
11
+ databaseAttribute: Attribute,
12
+ configAttribute: Attribute
13
+ ): boolean => {
14
+ return (
15
+ databaseAttribute.key == configAttribute.key &&
16
+ databaseAttribute.type == configAttribute.type &&
17
+ databaseAttribute.array == configAttribute.array
18
+ );
47
19
  };
48
20
 
49
21
  export const createOrUpdateAttribute = async (
@@ -53,36 +25,90 @@ export const createOrUpdateAttribute = async (
53
25
  attribute: Attribute
54
26
  ): Promise<void> => {
55
27
  let action = "create";
56
- let foundAttribute;
28
+ let foundAttribute: Attribute | undefined;
29
+ const updateEnabled = false;
30
+ let finalAttribute: any = attribute;
57
31
  try {
58
- foundAttribute = await db.getAttribute(dbId, collection.$id, attribute.key);
59
- foundAttribute = parseAttribute(foundAttribute);
32
+ const collectionAttr = collection.attributes.find(
33
+ // @ts-expect-error
34
+ (attr) => attr.key === attribute.key
35
+ ) as unknown;
36
+ foundAttribute = parseAttribute(collectionAttr);
60
37
  } catch (error) {
61
38
  foundAttribute = undefined;
62
39
  }
63
- let numSameAttributes = 0;
64
- if (foundAttribute && attributesSame(foundAttribute, attribute)) {
65
- numSameAttributes++;
66
- return;
67
- } else if (foundAttribute && !attributesSame(foundAttribute, attribute)) {
40
+
41
+ if (
42
+ foundAttribute &&
43
+ attributesSame(foundAttribute, attribute) &&
44
+ updateEnabled
45
+ ) {
46
+ // Check if mutable properties have changed and set action to "update" if necessary
47
+ const requiredChanged =
48
+ "required" in foundAttribute && "required" in attribute
49
+ ? foundAttribute.required !== attribute.required
50
+ : false;
51
+
52
+ // const xdefaultChanged =
53
+ // "xdefault" in foundAttribute && "xdefault" in attribute
54
+ // ? foundAttribute.xdefault !== attribute.xdefault
55
+ // : false;
56
+
57
+ const onDeleteChanged =
58
+ foundAttribute.type === "relationship" &&
59
+ attribute.type === "relationship" &&
60
+ "onDelete" in foundAttribute &&
61
+ "onDelete" in attribute
62
+ ? foundAttribute.onDelete !== attribute.onDelete
63
+ : false;
64
+
65
+ if (requiredChanged || onDeleteChanged) {
66
+ console.log(
67
+ `Required changed: ${requiredChanged}\nOnDelete changed: ${onDeleteChanged}`
68
+ );
69
+ console.log(
70
+ `Found attribute: ${JSON.stringify(foundAttribute, null, 2)}`
71
+ );
72
+ console.log(`Attribute: ${JSON.stringify(attribute, null, 2)}`);
73
+ finalAttribute = {
74
+ ...attribute,
75
+ ...foundAttribute,
76
+ };
77
+ action = "update";
78
+ } else {
79
+ // If no properties that can be updated have changed, return early
80
+ return;
81
+ }
82
+ } else if (
83
+ foundAttribute &&
84
+ !attributesSame(foundAttribute, attribute) &&
85
+ updateEnabled
86
+ ) {
68
87
  console.log(
69
- `Deleting attribute with same key ${attribute.key} -- ${
70
- foundAttribute.key
71
- } but different values -- ${JSON.stringify(
88
+ `Deleting attribute with same key ${
89
+ attribute.key
90
+ } -- but different values -- ${JSON.stringify(
72
91
  attribute,
73
92
  null,
74
93
  2
75
94
  )} -- ${JSON.stringify(foundAttribute, null, 2)}`
76
95
  );
77
96
  await db.deleteAttribute(dbId, collection.$id, attribute.key);
97
+ // After deletion, you might want to create the attribute anew
98
+ finalAttribute = attribute;
99
+ action = "create";
100
+ } else if (!updateEnabled && foundAttribute) {
101
+ return;
78
102
  }
79
103
 
80
104
  // Relationship attribute logic with adjustments
81
105
  let collectionFoundViaRelatedCollection: Models.Collection | undefined;
82
106
  let relatedCollectionId: string | undefined;
83
- if (attribute.type === "relationship") {
84
- if (nameToIdMapping.has(attribute.relatedCollection)) {
85
- relatedCollectionId = nameToIdMapping.get(attribute.relatedCollection);
107
+ if (finalAttribute.type === "relationship") {
108
+ if (nameToIdMapping.has(finalAttribute.relatedCollection)) {
109
+ relatedCollectionId = nameToIdMapping.get(
110
+ finalAttribute.relatedCollection
111
+ );
86
112
  try {
87
113
  collectionFoundViaRelatedCollection = await db.getCollection(
88
114
  dbId,
@@ -90,77 +116,104 @@ export const createOrUpdateAttribute = async (
90
116
  );
91
117
  } catch (e) {
92
118
  console.log(
93
- `Collection not found: ${attribute.relatedCollection} when nameToIdMapping was set`
119
+ `Collection not found: ${finalAttribute.relatedCollection} when nameToIdMapping was set`
94
120
  );
95
121
  collectionFoundViaRelatedCollection = undefined;
96
122
  }
97
123
  } else {
98
124
  const collectionsPulled = await db.listCollections(dbId, [
99
- Query.equal("name", attribute.relatedCollection),
125
+ Query.equal("name", finalAttribute.relatedCollection),
100
126
  ]);
101
127
  if (collectionsPulled.total > 0) {
102
128
  collectionFoundViaRelatedCollection = collectionsPulled.collections[0];
103
129
  relatedCollectionId = collectionFoundViaRelatedCollection.$id;
104
- nameToIdMapping.set(attribute.relatedCollection, relatedCollectionId);
130
+ nameToIdMapping.set(
131
+ finalAttribute.relatedCollection,
132
+ relatedCollectionId
133
+ );
105
134
  }
106
135
  }
107
136
  if (!(relatedCollectionId && collectionFoundViaRelatedCollection)) {
108
- console.log(`Enqueueing operation for attribute: ${attribute.key}`);
137
+ console.log(`Enqueueing operation for attribute: ${finalAttribute.key}`);
109
138
  enqueueOperation({
110
139
  type: "attribute",
111
140
  collectionId: collection.$id,
112
141
  collection: collection,
113
142
  attribute,
114
- dependencies: [attribute.relatedCollection],
143
+ dependencies: [finalAttribute.relatedCollection],
115
144
  });
116
145
  return;
117
146
  }
118
147
  }
119
-
120
- switch (attribute.type) {
148
+ finalAttribute = attributeSchema.parse(finalAttribute);
149
+ switch (finalAttribute.type) {
121
150
  case "string":
122
151
  if (action === "create") {
123
152
  await db.createStringAttribute(
124
153
  dbId,
125
154
  collection.$id,
126
- attribute.key,
127
- attribute.size,
128
- attribute.required,
129
- attribute.xdefault || undefined,
130
- attribute.array,
131
- attribute.encrypted
155
+ finalAttribute.key,
156
+ finalAttribute.size,
157
+ finalAttribute.required || false,
158
+ (finalAttribute.xdefault as string) || undefined,
159
+ finalAttribute.array || false,
160
+ finalAttribute.encrypted
132
161
  );
133
162
  } else {
134
163
  await db.updateStringAttribute(
135
164
  dbId,
136
165
  collection.$id,
137
- attribute.key,
138
- attribute.required,
139
- attribute.xdefault || undefined
166
+ finalAttribute.key,
167
+ finalAttribute.required || false,
168
+ (finalAttribute.xdefault as string) || undefined
140
169
  );
141
170
  }
142
171
  break;
143
172
  case "integer":
144
173
  if (action === "create") {
174
+ if (
175
+ finalAttribute.min &&
176
+ BigInt(finalAttribute.min) === BigInt(-9223372036854776000)
177
+ ) {
178
+ delete finalAttribute.min;
179
+ }
180
+ if (
181
+ finalAttribute.max &&
182
+ BigInt(finalAttribute.max) === BigInt(9223372036854776000)
183
+ ) {
184
+ delete finalAttribute.max;
185
+ }
145
186
  await db.createIntegerAttribute(
146
187
  dbId,
147
188
  collection.$id,
148
- attribute.key,
149
- attribute.required,
150
- attribute.min,
151
- attribute.max,
152
- attribute.xdefault || undefined,
153
- attribute.array
189
+ finalAttribute.key,
190
+ finalAttribute.required || false,
191
+ finalAttribute.min,
192
+ finalAttribute.max,
193
+ finalAttribute.xdefault || undefined,
194
+ finalAttribute.array
154
195
  );
155
196
  } else {
197
+ if (
198
+ finalAttribute.min &&
199
+ BigInt(finalAttribute.min) === BigInt(-9223372036854776000)
200
+ ) {
201
+ delete finalAttribute.min;
202
+ }
203
+ if (
204
+ finalAttribute.max &&
205
+ BigInt(finalAttribute.max) === BigInt(9223372036854776000)
206
+ ) {
207
+ delete finalAttribute.max;
208
+ }
156
209
  await db.updateIntegerAttribute(
157
210
  dbId,
158
211
  collection.$id,
159
- attribute.key,
160
- attribute.required,
161
- attribute.min || 0,
162
- attribute.max || 2147483647,
163
- attribute.xdefault || undefined
212
+ finalAttribute.key,
213
+ finalAttribute.required || false,
214
+ finalAttribute.min || 0,
215
+ finalAttribute.max || 2147483647,
216
+ finalAttribute.xdefault || undefined
164
217
  );
165
218
  }
166
219
  break;
@@ -169,22 +222,22 @@ export const createOrUpdateAttribute = async (
169
222
  await db.createFloatAttribute(
170
223
  dbId,
171
224
  collection.$id,
172
- attribute.key,
173
- attribute.required,
174
- attribute.min,
175
- attribute.max,
176
- attribute.xdefault || undefined,
177
- attribute.array
225
+ finalAttribute.key,
226
+ finalAttribute.required || false,
227
+ finalAttribute.min,
228
+ finalAttribute.max,
229
+ finalAttribute.xdefault || undefined,
230
+ finalAttribute.array
178
231
  );
179
232
  } else {
180
233
  await db.updateFloatAttribute(
181
234
  dbId,
182
235
  collection.$id,
183
- attribute.key,
184
- attribute.required,
185
- attribute.min || 0,
186
- attribute.max || 2147483647,
187
- attribute.xdefault || undefined
236
+ finalAttribute.key,
237
+ finalAttribute.required || false,
238
+ finalAttribute.min || 0,
239
+ finalAttribute.max || 2147483647,
240
+ finalAttribute.xdefault || undefined
188
241
  );
189
242
  }
190
243
  break;
@@ -193,18 +246,18 @@ export const createOrUpdateAttribute = async (
193
246
  await db.createBooleanAttribute(
194
247
  dbId,
195
248
  collection.$id,
196
- attribute.key,
197
- attribute.required,
198
- attribute.xdefault || undefined,
199
- attribute.array
249
+ finalAttribute.key,
250
+ finalAttribute.required || false,
251
+ finalAttribute.xdefault || undefined,
252
+ finalAttribute.array
200
253
  );
201
254
  } else {
202
255
  await db.updateBooleanAttribute(
203
256
  dbId,
204
257
  collection.$id,
205
- attribute.key,
206
- attribute.required,
207
- attribute.xdefault || undefined
258
+ finalAttribute.key,
259
+ finalAttribute.required || false,
260
+ finalAttribute.xdefault || null
208
261
  );
209
262
  }
210
263
  break;
@@ -213,18 +266,18 @@ export const createOrUpdateAttribute = async (
213
266
  await db.createDatetimeAttribute(
214
267
  dbId,
215
268
  collection.$id,
216
- attribute.key,
217
- attribute.required,
218
- attribute.xdefault || undefined,
219
- attribute.array
269
+ finalAttribute.key,
270
+ finalAttribute.required || false,
271
+ finalAttribute.xdefault || undefined,
272
+ finalAttribute.array
220
273
  );
221
274
  } else {
222
275
  await db.updateDatetimeAttribute(
223
276
  dbId,
224
277
  collection.$id,
225
- attribute.key,
226
- attribute.required,
227
- attribute.xdefault || undefined
278
+ finalAttribute.key,
279
+ finalAttribute.required || false,
280
+ finalAttribute.xdefault || undefined
228
281
  );
229
282
  }
230
283
  break;
@@ -233,18 +286,18 @@ export const createOrUpdateAttribute = async (
233
286
  await db.createEmailAttribute(
234
287
  dbId,
235
288
  collection.$id,
236
- attribute.key,
237
- attribute.required,
238
- attribute.xdefault || undefined,
239
- attribute.array
289
+ finalAttribute.key,
290
+ finalAttribute.required || false,
291
+ finalAttribute.xdefault || undefined,
292
+ finalAttribute.array
240
293
  );
241
294
  } else {
242
295
  await db.updateEmailAttribute(
243
296
  dbId,
244
297
  collection.$id,
245
- attribute.key,
246
- attribute.required,
247
- attribute.xdefault || undefined
298
+ finalAttribute.key,
299
+ finalAttribute.required || false,
300
+ finalAttribute.xdefault || undefined
248
301
  );
249
302
  }
250
303
  break;
@@ -253,18 +306,18 @@ export const createOrUpdateAttribute = async (
253
306
  await db.createIpAttribute(
254
307
  dbId,
255
308
  collection.$id,
256
- attribute.key,
257
- attribute.required,
258
- attribute.xdefault || undefined,
259
- attribute.array
309
+ finalAttribute.key,
310
+ finalAttribute.required || false,
311
+ finalAttribute.xdefault || undefined,
312
+ finalAttribute.array
260
313
  );
261
314
  } else {
262
315
  await db.updateIpAttribute(
263
316
  dbId,
264
317
  collection.$id,
265
- attribute.key,
266
- attribute.required,
267
- attribute.xdefault || undefined
318
+ finalAttribute.key,
319
+ finalAttribute.required || false,
320
+ finalAttribute.xdefault || undefined
268
321
  );
269
322
  }
270
323
  break;
@@ -273,18 +326,18 @@ export const createOrUpdateAttribute = async (
273
326
  await db.createUrlAttribute(
274
327
  dbId,
275
328
  collection.$id,
276
- attribute.key,
277
- attribute.required,
278
- attribute.xdefault || undefined,
279
- attribute.array
329
+ finalAttribute.key,
330
+ finalAttribute.required || false,
331
+ finalAttribute.xdefault || undefined,
332
+ finalAttribute.array
280
333
  );
281
334
  } else {
282
335
  await db.updateUrlAttribute(
283
336
  dbId,
284
337
  collection.$id,
285
- attribute.key,
286
- attribute.required,
287
- attribute.xdefault || undefined
338
+ finalAttribute.key,
339
+ finalAttribute.required || false,
340
+ finalAttribute.xdefault || undefined
288
341
  );
289
342
  }
290
343
  break;
@@ -293,20 +346,20 @@ export const createOrUpdateAttribute = async (
293
346
  await db.createEnumAttribute(
294
347
  dbId,
295
348
  collection.$id,
296
- attribute.key,
297
- attribute.elements,
298
- attribute.required,
299
- attribute.xdefault || undefined,
300
- attribute.array
349
+ finalAttribute.key,
350
+ finalAttribute.elements,
351
+ finalAttribute.required || false,
352
+ finalAttribute.xdefault || undefined,
353
+ finalAttribute.array
301
354
  );
302
355
  } else {
303
356
  await db.updateEnumAttribute(
304
357
  dbId,
305
358
  collection.$id,
306
- attribute.key,
307
- attribute.elements,
308
- attribute.required,
309
- attribute.xdefault || undefined
359
+ finalAttribute.key,
360
+ finalAttribute.elements,
361
+ finalAttribute.required || false,
362
+ finalAttribute.xdefault || undefined
310
363
  );
311
364
  }
312
365
  break;
@@ -316,18 +369,18 @@ export const createOrUpdateAttribute = async (
316
369
  dbId,
317
370
  collection.$id,
318
371
  relatedCollectionId!,
319
- attribute.relationType,
320
- attribute.twoWay,
321
- attribute.key,
322
- attribute.twoWayKey,
323
- attribute.onDelete
372
+ finalAttribute.relationType,
373
+ finalAttribute.twoWay,
374
+ finalAttribute.key,
375
+ finalAttribute.twoWayKey,
376
+ finalAttribute.onDelete
324
377
  );
325
378
  } else {
326
379
  await db.updateRelationshipAttribute(
327
380
  dbId,
328
381
  collection.$id,
329
- attribute.key,
330
- attribute.onDelete
382
+ finalAttribute.key,
383
+ finalAttribute.onDelete
331
384
  );
332
385
  }
333
386
  break;
@@ -4,7 +4,7 @@ import {
4
4
  type Attribute,
5
5
  parseAttribute,
6
6
  CollectionCreateSchema,
7
- } from "./schema.js";
7
+ } from "appwrite-utils";
8
8
 
9
9
  export const BackupSchema = z.object({
10
10
  $id: z.string(),
@@ -1,19 +1,10 @@
1
1
  import { Databases, ID, Permission, Query, type Models } from "node-appwrite";
2
- import type { AppwriteConfig, CollectionCreate } from "./schema.js";
2
+ import type { AppwriteConfig, CollectionCreate } from "appwrite-utils";
3
3
  import { nameToIdMapping, processQueue } from "./queue.js";
4
4
  import { createUpdateCollectionAttributes } from "./attributes.js";
5
5
  import { createOrUpdateIndexes } from "./indexes.js";
6
- import {
7
- ensureDirectoryExistence,
8
- toCamelCase,
9
- toPascalCase,
10
- writeFileSync,
11
- } from "../utils/index.js";
12
6
  import _ from "lodash";
13
7
  import { SchemaGenerator } from "./schemaStrings.js";
14
- import path from "path";
15
-
16
- const { join } = _;
17
8
 
18
9
  export const documentExists = async (
19
10
  db: Databases,
@@ -157,6 +148,9 @@ export const createOrUpdateCollections = async (
157
148
  deletedCollections?: { collectionId: string; collectionName: string }[]
158
149
  ): Promise<void> => {
159
150
  const configCollections = config.collections;
151
+ if (!configCollections) {
152
+ return;
153
+ }
160
154
  const usedIds = new Set(); // To track IDs used in this operation
161
155
 
162
156
  for (const { attributes, indexes, ...collection } of configCollections) {
@@ -234,7 +228,7 @@ export const createOrUpdateCollections = async (
234
228
  continue; // Skip to the next collection on failure
235
229
  }
236
230
  } else {
237
- console.log(`Collection ${collection.name} already exists.`);
231
+ console.log(`Collection ${collection.name} exists, using it`);
238
232
  }
239
233
 
240
234
  // Update attributes and indexes for the collection
@@ -250,7 +244,7 @@ export const createOrUpdateCollections = async (
250
244
  databaseId,
251
245
  database,
252
246
  collectionToUse.$id,
253
- indexes
247
+ indexes ?? []
254
248
  );
255
249
  }
256
250
  // Process any remaining tasks in the queue