Files
wanderer/db/migrations/1734726340_created_notifications.go
Christian Beutel eca79758ec updates migrations
2025-03-17 00:03:56 +01:00

118 lines
2.5 KiB
Go

package migrations
import (
"encoding/json"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
jsonData := `{
"id": "khrcci2uqknny8h",
"created": "2024-12-20 17:33:49.887Z",
"updated": "2024-12-20 20:25:40.071Z",
"name": "notifications",
"type": "base",
"system": false,
"schema": [
{
"system": false,
"id": "b57prsbu",
"name": "type",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"trail_create",
"list_create",
"new_follower",
"trail_comment"
]
}
},
{
"system": false,
"id": "1i2ycgle",
"name": "metadata",
"type": "json",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSize": 2000000
}
},
{
"system": false,
"id": "pyimxu85",
"name": "seen",
"type": "bool",
"required": false,
"presentable": false,
"unique": false,
"options": {}
},
{
"system": false,
"id": "tmghd4vo",
"name": "recipient",
"type": "relation",
"required": true,
"presentable": false,
"unique": false,
"options": {
"collectionId": "_pb_users_auth_",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
},
{
"system": false,
"id": "exqo1whj",
"name": "author",
"type": "relation",
"required": true,
"presentable": false,
"unique": false,
"options": {
"collectionId": "_pb_users_auth_",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
}
],
"indexes": [],
"listRule": "@request.auth.id = recipient",
"viewRule": "@request.auth.id = recipient",
"createRule": null,
"updateRule": "@request.auth.id = recipient && @request.data.type = type && @request.data.metadata = metadata && @request.data.recipient = recipient && @request.data.author = author",
"deleteRule": null,
"options": {}
}`
collection := &core.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
if err != nil {
return err
}
return app.Delete(collection)
})
}