From a91b3a81efe7fa6b028ad6bc0f1e1ff62d97dab5 Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Sat, 19 Jul 2025 17:43:13 -0700 Subject: [PATCH] fix(mothership): add error handling for domain collection deletion --- .../1752933103_deleted_domains.js | 147 +++++++++--------- 1 file changed, 77 insertions(+), 70 deletions(-) diff --git a/packages/pockethost/src/mothership-app/pb_migrations/1752933103_deleted_domains.js b/packages/pockethost/src/mothership-app/pb_migrations/1752933103_deleted_domains.js index 47aead84..66d7e0bc 100644 --- a/packages/pockethost/src/mothership-app/pb_migrations/1752933103_deleted_domains.js +++ b/packages/pockethost/src/mothership-app/pb_migrations/1752933103_deleted_domains.js @@ -1,73 +1,80 @@ /// -migrate((db) => { - const dao = new Dao(db); - const collection = dao.findCollectionByNameOrId("jw1wz9nmkvnhcm6"); +migrate( + (db) => { + const dao = new Dao(db) + try { + const collection = dao.findCollectionByNameOrId('jw1wz9nmkvnhcm6') - return dao.deleteCollection(collection); -}, (db) => { - const collection = new Collection({ - "id": "jw1wz9nmkvnhcm6", - "created": "2025-07-18 05:18:37.698Z", - "updated": "2025-07-19 01:09:48.781Z", - "name": "domains", - "type": "base", - "system": false, - "schema": [ - { - "system": false, - "id": "fhie5snn", - "name": "instance", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "etae8tuiaxl6xfv", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": 1, - "displayFields": null - } - }, - { - "system": false, - "id": "wn3oncif", - "name": "domain", - "type": "text", - "required": false, - "presentable": true, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - }, - { - "system": false, - "id": "vzkcvhhg", - "name": "active", - "type": "bool", - "required": false, - "presentable": false, - "unique": false, - "options": {} - } - ], - "indexes": [ - "CREATE UNIQUE INDEX `idx_gtGcwf2` ON `domains` (`domain`)", - "CREATE INDEX `idx_OtPOwXe` ON `domains` (`instance`)", - "CREATE INDEX `idx_0omsTdi` ON `domains` (`created`)", - "CREATE INDEX `idx_uMaIOVQ` ON `domains` (`updated`)", - "CREATE UNIQUE INDEX `idx_VLBOSap` ON `domains` (\n `instance`,\n `domain`\n)" - ], - "listRule": "@request.auth.id=instance.uid", - "viewRule": "@request.auth.id=instance.uid", - "createRule": null, - "updateRule": null, - "deleteRule": null, - "options": {} - }); + return dao.deleteCollection(collection) + } catch (e) { + console.error(e) + } + }, + (db) => { + const collection = new Collection({ + id: 'jw1wz9nmkvnhcm6', + created: '2025-07-18 05:18:37.698Z', + updated: '2025-07-19 01:09:48.781Z', + name: 'domains', + type: 'base', + system: false, + schema: [ + { + system: false, + id: 'fhie5snn', + name: 'instance', + type: 'relation', + required: false, + presentable: false, + unique: false, + options: { + collectionId: 'etae8tuiaxl6xfv', + cascadeDelete: false, + minSelect: null, + maxSelect: 1, + displayFields: null, + }, + }, + { + system: false, + id: 'wn3oncif', + name: 'domain', + type: 'text', + required: false, + presentable: true, + unique: false, + options: { + min: null, + max: null, + pattern: '', + }, + }, + { + system: false, + id: 'vzkcvhhg', + name: 'active', + type: 'bool', + required: false, + presentable: false, + unique: false, + options: {}, + }, + ], + indexes: [ + 'CREATE UNIQUE INDEX `idx_gtGcwf2` ON `domains` (`domain`)', + 'CREATE INDEX `idx_OtPOwXe` ON `domains` (`instance`)', + 'CREATE INDEX `idx_0omsTdi` ON `domains` (`created`)', + 'CREATE INDEX `idx_uMaIOVQ` ON `domains` (`updated`)', + 'CREATE UNIQUE INDEX `idx_VLBOSap` ON `domains` (\n `instance`,\n `domain`\n)', + ], + listRule: '@request.auth.id=instance.uid', + viewRule: '@request.auth.id=instance.uid', + createRule: null, + updateRule: null, + deleteRule: null, + options: {}, + }) - return Dao(db).saveCollection(collection); -}) + return Dao(db).saveCollection(collection) + } +)