pocketbase_demo/pb_migrations/1771449395_updated_article_block.js

150 lines
3.1 KiB
JavaScript

/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_3952495299")
// update collection data
unmarshal({
"listRule": ""
}, collection)
// remove field
collection.fields.removeById("_clone_GmaI")
// remove field
collection.fields.removeById("_clone_sCu7")
// remove field
collection.fields.removeById("_clone_NUEy")
// remove field
collection.fields.removeById("_clone_qbMV")
// add field
collection.fields.addAt(1, new Field({
"autogeneratePattern": "[A-Z][-A-Za-z _]{10-40}",
"hidden": false,
"id": "_clone_Fcoh",
"max": 0,
"min": 0,
"name": "title",
"pattern": "[A-Z].*",
"presentable": true,
"primaryKey": false,
"required": true,
"system": false,
"type": "text"
}))
// add field
collection.fields.addAt(2, new Field({
"convertURLs": false,
"hidden": false,
"id": "_clone_IrsT",
"maxSize": 0,
"name": "body",
"presentable": false,
"required": false,
"system": false,
"type": "editor"
}))
// add field
collection.fields.addAt(3, new Field({
"hidden": false,
"id": "_clone_XZfK",
"name": "created",
"onCreate": true,
"onUpdate": false,
"presentable": false,
"system": false,
"type": "autodate"
}))
// add field
collection.fields.addAt(4, new Field({
"hidden": false,
"id": "_clone_BqKS",
"name": "updated",
"onCreate": true,
"onUpdate": true,
"presentable": false,
"system": false,
"type": "autodate"
}))
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_3952495299")
// update collection data
unmarshal({
"listRule": null
}, collection)
// add field
collection.fields.addAt(1, new Field({
"autogeneratePattern": "[A-Z][-A-Za-z _]{10-40}",
"hidden": false,
"id": "_clone_GmaI",
"max": 0,
"min": 0,
"name": "title",
"pattern": "[A-Z].*",
"presentable": true,
"primaryKey": false,
"required": true,
"system": false,
"type": "text"
}))
// add field
collection.fields.addAt(2, new Field({
"convertURLs": false,
"hidden": false,
"id": "_clone_sCu7",
"maxSize": 0,
"name": "body",
"presentable": false,
"required": false,
"system": false,
"type": "editor"
}))
// add field
collection.fields.addAt(3, new Field({
"hidden": false,
"id": "_clone_NUEy",
"name": "created",
"onCreate": true,
"onUpdate": false,
"presentable": false,
"system": false,
"type": "autodate"
}))
// add field
collection.fields.addAt(4, new Field({
"hidden": false,
"id": "_clone_qbMV",
"name": "updated",
"onCreate": true,
"onUpdate": true,
"presentable": false,
"system": false,
"type": "autodate"
}))
// remove field
collection.fields.removeById("_clone_Fcoh")
// remove field
collection.fields.removeById("_clone_IrsT")
// remove field
collection.fields.removeById("_clone_XZfK")
// remove field
collection.fields.removeById("_clone_BqKS")
return app.save(collection)
})