diff --git a/pb_migrations/1779200000_updated_sources.js b/pb_migrations/1779200000_updated_sources.js new file mode 100644 index 0000000..b78c630 --- /dev/null +++ b/pb_migrations/1779200000_updated_sources.js @@ -0,0 +1,45 @@ +/// +migrate((app) => { + const collection = app.findCollectionByNameOrId("pbc_1124997656") + + if (collection) { + // Check if created already exists + let hasCreated = false; + for (let f of collection.fields) { + if (f.name === 'created') hasCreated = true; + } + + if (!hasCreated) { + collection.fields.addAt(4, new Field({ + "hidden": false, + "id": "autodate_sources_created", + "name": "created", + "onCreate": true, + "onUpdate": false, + "presentable": false, + "system": false, + "type": "autodate" + })) + + collection.fields.addAt(5, new Field({ + "hidden": false, + "id": "autodate_sources_updated", + "name": "updated", + "onCreate": true, + "onUpdate": true, + "presentable": false, + "system": false, + "type": "autodate" + })) + + return app.save(collection) + } + } +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_1124997656") + if (collection) { + collection.fields.removeById("autodate_sources_created") + collection.fields.removeById("autodate_sources_updated") + return app.save(collection) + } +})