diff --git a/pb_migrations/1772333711_created_projects.js b/pb_migrations/1772333711_created_projects.js new file mode 100644 index 0000000..760dffa --- /dev/null +++ b/pb_migrations/1772333711_created_projects.js @@ -0,0 +1,86 @@ +/// +migrate((app) => { + const collection = new Collection({ + "createRule": null, + "deleteRule": null, + "fields": [ + { + "autogeneratePattern": "[a-z0-9]{15}", + "hidden": false, + "id": "text3208210256", + "max": 15, + "min": 15, + "name": "id", + "pattern": "^[a-z0-9]+$", + "presentable": false, + "primaryKey": true, + "required": true, + "system": true, + "type": "text" + }, + { + "autogeneratePattern": "", + "hidden": false, + "id": "text1579384326", + "max": 50, + "min": 2, + "name": "name", + "pattern": "", + "presentable": false, + "primaryKey": false, + "required": true, + "system": false, + "type": "text" + }, + { + "cascadeDelete": true, + "collectionId": "_pb_users_auth_", + "hidden": false, + "id": "relation2375276105", + "maxSelect": 1, + "minSelect": 0, + "name": "user", + "presentable": false, + "required": true, + "system": false, + "type": "relation" + }, + { + "hidden": false, + "id": "autodate2990389176", + "name": "created", + "onCreate": true, + "onUpdate": false, + "presentable": false, + "system": false, + "type": "autodate" + }, + { + "hidden": false, + "id": "autodate3332085495", + "name": "updated", + "onCreate": true, + "onUpdate": true, + "presentable": false, + "system": false, + "type": "autodate" + } + ], + "id": "pbc_484305853", + "indexes": [ + "CREATE UNIQUE INDEX `idx_unique_projects_name` ON `projects` (LOWER(name))" + ], + "listRule": "", + "name": "projects", + "system": false, + "type": "base", + "updateRule": null, + "viewRule": null + }); + + return app.save(collection); +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_484305853"); + + return app.delete(collection); +}) diff --git a/pb_migrations/1772333935_updated_projects.js b/pb_migrations/1772333935_updated_projects.js new file mode 100644 index 0000000..c76aa9e --- /dev/null +++ b/pb_migrations/1772333935_updated_projects.js @@ -0,0 +1,28 @@ +/// +migrate((app) => { + const collection = app.findCollectionByNameOrId("pbc_484305853") + + // update collection data + unmarshal({ + "createRule": "@request.auth.id != \"\" && @request.auth.id = @request.body.user.id", + "deleteRule": "@request.auth.id != \"\" && @request.auth.id = user.id", + "listRule": "@request.auth.id != \"\" && @request.auth.id = user.id", + "updateRule": "@request.auth.id != \"\" && @request.auth.id = user.id", + "viewRule": "@request.auth.id = user.id" + }, collection) + + return app.save(collection) +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_484305853") + + // update collection data + unmarshal({ + "createRule": null, + "deleteRule": null, + "listRule": "", + "updateRule": null, + "viewRule": null + }, collection) + + return app.save(collection) +})