170 lines
5.1 KiB
JavaScript
170 lines
5.1 KiB
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|
migrate((app) => {
|
|
const collection = new Collection({
|
|
"createRule": "",
|
|
"deleteRule": "@request.auth.collectionName = 'users' && @request.auth.role = 'admin'",
|
|
"fields": [
|
|
{
|
|
"autogeneratePattern": "[a-z0-9]{15}",
|
|
"hidden": false,
|
|
"id": "text3930877004",
|
|
"max": 15,
|
|
"min": 15,
|
|
"name": "id",
|
|
"pattern": "^[a-z0-9]+$",
|
|
"presentable": false,
|
|
"primaryKey": true,
|
|
"required": true,
|
|
"system": true,
|
|
"type": "text"
|
|
},
|
|
{
|
|
"hidden": false,
|
|
"id": "text9496940303",
|
|
"name": "firstName",
|
|
"presentable": false,
|
|
"primaryKey": false,
|
|
"required": true,
|
|
"system": false,
|
|
"type": "text",
|
|
"autogeneratePattern": "",
|
|
"max": 0,
|
|
"min": 0,
|
|
"pattern": ""
|
|
},
|
|
{
|
|
"hidden": false,
|
|
"id": "text6526030650",
|
|
"name": "lastName",
|
|
"presentable": false,
|
|
"primaryKey": false,
|
|
"required": true,
|
|
"system": false,
|
|
"type": "text",
|
|
"autogeneratePattern": "",
|
|
"max": 0,
|
|
"min": 0,
|
|
"pattern": ""
|
|
},
|
|
{
|
|
"hidden": false,
|
|
"id": "text1504649217",
|
|
"name": "email",
|
|
"presentable": false,
|
|
"primaryKey": false,
|
|
"required": true,
|
|
"system": false,
|
|
"type": "text",
|
|
"autogeneratePattern": "",
|
|
"max": 0,
|
|
"min": 0,
|
|
"pattern": ""
|
|
},
|
|
{
|
|
"hidden": false,
|
|
"id": "text3766238150",
|
|
"name": "industry",
|
|
"presentable": false,
|
|
"primaryKey": false,
|
|
"required": true,
|
|
"system": false,
|
|
"type": "text",
|
|
"autogeneratePattern": "",
|
|
"max": 0,
|
|
"min": 0,
|
|
"pattern": ""
|
|
},
|
|
{
|
|
"hidden": false,
|
|
"id": "text0206998537",
|
|
"name": "websites",
|
|
"presentable": false,
|
|
"primaryKey": false,
|
|
"required": true,
|
|
"system": false,
|
|
"type": "text",
|
|
"autogeneratePattern": "",
|
|
"max": 0,
|
|
"min": 0,
|
|
"pattern": ""
|
|
},
|
|
{
|
|
"hidden": false,
|
|
"id": "text1142803244",
|
|
"name": "applications",
|
|
"presentable": false,
|
|
"primaryKey": false,
|
|
"required": true,
|
|
"system": false,
|
|
"type": "text",
|
|
"autogeneratePattern": "",
|
|
"max": 0,
|
|
"min": 0,
|
|
"pattern": ""
|
|
},
|
|
{
|
|
"hidden": false,
|
|
"id": "text6766822077",
|
|
"name": "systems",
|
|
"presentable": false,
|
|
"primaryKey": false,
|
|
"required": true,
|
|
"system": false,
|
|
"type": "text",
|
|
"autogeneratePattern": "",
|
|
"max": 0,
|
|
"min": 0,
|
|
"pattern": ""
|
|
},
|
|
{
|
|
"hidden": false,
|
|
"id": "autodate1878312857",
|
|
"name": "created",
|
|
"onCreate": true,
|
|
"onUpdate": false,
|
|
"presentable": false,
|
|
"system": false,
|
|
"type": "autodate"
|
|
},
|
|
{
|
|
"hidden": false,
|
|
"id": "autodate5206414872",
|
|
"name": "updated",
|
|
"onCreate": true,
|
|
"onUpdate": true,
|
|
"presentable": false,
|
|
"system": false,
|
|
"type": "autodate"
|
|
}
|
|
],
|
|
"id": "pbc_6716256996",
|
|
"indexes": [],
|
|
"listRule": "@request.auth.collectionName = 'users' && @request.auth.role = 'admin'",
|
|
"name": "assessments",
|
|
"system": false,
|
|
"type": "base",
|
|
"updateRule": "@request.auth.collectionName = 'users' && @request.auth.role = 'admin'",
|
|
"viewRule": "@request.auth.collectionName = 'users' && @request.auth.role = 'admin'"
|
|
});
|
|
|
|
try {
|
|
return app.save(collection);
|
|
} catch (e) {
|
|
if (e.message.includes("Collection name must be unique")) {
|
|
console.log("Collection already exists, skipping");
|
|
return;
|
|
}
|
|
throw e;
|
|
}
|
|
}, (app) => {
|
|
try {
|
|
const collection = app.findCollectionByNameOrId("pbc_6716256996");
|
|
return app.delete(collection);
|
|
} catch (e) {
|
|
if (e.message.includes("no rows in result set")) {
|
|
console.log("Collection not found, skipping revert");
|
|
return;
|
|
}
|
|
throw e;
|
|
}
|
|
}) |