Files
gamegroup2/backend/pb_migrations/1776424601_updated_users.js
T
2026-04-17 19:35:15 +08:00

195 lines
3.8 KiB
JavaScript

/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "sf_status",
"name": "status",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"idle",
"working",
"in_team",
"away"
]
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "sf_note",
"name": "statusNote",
"type": "text",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": 200,
"pattern": ""
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "sf_maxgroups",
"name": "maxGroups",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": 1,
"max": 20,
"noDecimal": true
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "sf_workdays",
"name": "workdays",
"type": "json",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSize": 500
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "sf_workstart",
"name": "workStartTime",
"type": "text",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": 5,
"pattern": ""
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "sf_nextwork",
"name": "nextWorkTime",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": true
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "sf_points",
"name": "points",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": true
}
}))
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "users_avatar",
"name": "avatar",
"type": "file",
"required": false,
"presentable": false,
"unique": false,
"options": {
"mimeTypes": [
"image/png",
"image/jpeg",
"image/svg+xml",
"image/gif"
],
"thumbs": null,
"maxSelect": 1,
"maxSize": 5242880,
"protected": false
}
}))
return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")
// remove
collection.schema.removeField("sf_status")
// remove
collection.schema.removeField("sf_note")
// remove
collection.schema.removeField("sf_maxgroups")
// remove
collection.schema.removeField("sf_workdays")
// remove
collection.schema.removeField("sf_workstart")
// remove
collection.schema.removeField("sf_nextwork")
// remove
collection.schema.removeField("sf_points")
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "users_avatar",
"name": "avatar",
"type": "file",
"required": false,
"presentable": false,
"unique": false,
"options": {
"mimeTypes": [
"image/jpeg",
"image/png",
"image/svg+xml",
"image/gif",
"image/webp"
],
"thumbs": null,
"maxSelect": 1,
"maxSize": 5242880,
"protected": false
}
}))
return dao.saveCollection(collection)
})