fix(mothership): add error handling for domain collection deletion

This commit is contained in:
Ben Allfree 2025-07-19 17:43:13 -07:00
parent 722d2f523c
commit a91b3a81ef

View File

@ -1,73 +1,80 @@
/// <reference path="../pb_data/types.d.ts" /> /// <reference path="../pb_data/types.d.ts" />
migrate((db) => { migrate(
const dao = new Dao(db); (db) => {
const collection = dao.findCollectionByNameOrId("jw1wz9nmkvnhcm6"); const dao = new Dao(db)
try {
const collection = dao.findCollectionByNameOrId('jw1wz9nmkvnhcm6')
return dao.deleteCollection(collection); return dao.deleteCollection(collection)
}, (db) => { } catch (e) {
const collection = new Collection({ console.error(e)
"id": "jw1wz9nmkvnhcm6", }
"created": "2025-07-18 05:18:37.698Z", },
"updated": "2025-07-19 01:09:48.781Z", (db) => {
"name": "domains", const collection = new Collection({
"type": "base", id: 'jw1wz9nmkvnhcm6',
"system": false, created: '2025-07-18 05:18:37.698Z',
"schema": [ updated: '2025-07-19 01:09:48.781Z',
{ name: 'domains',
"system": false, type: 'base',
"id": "fhie5snn", system: false,
"name": "instance", schema: [
"type": "relation", {
"required": false, system: false,
"presentable": false, id: 'fhie5snn',
"unique": false, name: 'instance',
"options": { type: 'relation',
"collectionId": "etae8tuiaxl6xfv", required: false,
"cascadeDelete": false, presentable: false,
"minSelect": null, unique: false,
"maxSelect": 1, options: {
"displayFields": null collectionId: 'etae8tuiaxl6xfv',
} cascadeDelete: false,
}, minSelect: null,
{ maxSelect: 1,
"system": false, displayFields: null,
"id": "wn3oncif", },
"name": "domain", },
"type": "text", {
"required": false, system: false,
"presentable": true, id: 'wn3oncif',
"unique": false, name: 'domain',
"options": { type: 'text',
"min": null, required: false,
"max": null, presentable: true,
"pattern": "" unique: false,
} options: {
}, min: null,
{ max: null,
"system": false, pattern: '',
"id": "vzkcvhhg", },
"name": "active", },
"type": "bool", {
"required": false, system: false,
"presentable": false, id: 'vzkcvhhg',
"unique": false, name: 'active',
"options": {} type: 'bool',
} required: false,
], presentable: false,
"indexes": [ unique: false,
"CREATE UNIQUE INDEX `idx_gtGcwf2` ON `domains` (`domain`)", options: {},
"CREATE INDEX `idx_OtPOwXe` ON `domains` (`instance`)", },
"CREATE INDEX `idx_0omsTdi` ON `domains` (`created`)", ],
"CREATE INDEX `idx_uMaIOVQ` ON `domains` (`updated`)", indexes: [
"CREATE UNIQUE INDEX `idx_VLBOSap` ON `domains` (\n `instance`,\n `domain`\n)" 'CREATE UNIQUE INDEX `idx_gtGcwf2` ON `domains` (`domain`)',
], 'CREATE INDEX `idx_OtPOwXe` ON `domains` (`instance`)',
"listRule": "@request.auth.id=instance.uid", 'CREATE INDEX `idx_0omsTdi` ON `domains` (`created`)',
"viewRule": "@request.auth.id=instance.uid", 'CREATE INDEX `idx_uMaIOVQ` ON `domains` (`updated`)',
"createRule": null, 'CREATE UNIQUE INDEX `idx_VLBOSap` ON `domains` (\n `instance`,\n `domain`\n)',
"updateRule": null, ],
"deleteRule": null, listRule: '@request.auth.id=instance.uid',
"options": {} viewRule: '@request.auth.id=instance.uid',
}); createRule: null,
updateRule: null,
deleteRule: null,
options: {},
})
return Dao(db).saveCollection(collection); return Dao(db).saveCollection(collection)
}) }
)