Files
gamegroup2/backend/pb_migrations/1776938195_updated_games_cover_to_file.js
T

52 lines
1.2 KiB
JavaScript
Raw Normal View History

/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("x5adjlc0txf16r8")
// remove old url cover field
collection.schema.removeField("cover_field")
// add new file cover field
collection.schema.addField(new SchemaField({
"system": false,
"id": "cover_file",
"name": "cover",
"type": "file",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"maxSize": 5242880,
"mimeTypes": ["image/jpeg","image/png","image/gif","image/webp","image/svg+xml"],
"thumbs": null,
"protected": false
}
}))
return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("x5adjlc0txf16r8")
// remove file cover field
collection.schema.removeField("cover_file")
// restore url cover field
collection.schema.addField(new SchemaField({
"system": false,
"id": "cover_field",
"name": "cover",
"type": "url",
"required": false,
"presentable": false,
"unique": false,
"options": {
"exceptDomains": null,
"onlyDomains": null
}
}))
return dao.saveCollection(collection)
})