* initial commit federation * more federation * more federation * more federation * completes follow, accept, undo * add trail create activity * process trail create activity * more trail create activity * adds missing endpoints * adds update and delete activity * adds comment activities * adds activities back * adds summit logs activities * deletes follow counts table * fixes migrations * fixes migrations * fixes migrations * fixes migrations * adds remote profiles * ctd * ctd * we are getting closer... * adds public summit logs * fixes federated trails in lists * adds remote lists * adds list activites * fixes lists * adds notifications * adds iri redirect * fixes comments and summitlogs * fixes follows and profiles * adds asynchronous send * fixes list search * adds encryption key * bug fixes * fixes activity signing * removes custon activity object types * adds html editor * fixes html editor * fixes display issues on mastodon * adds federated sharing * finishes announcements * fixes small summit log issues * adds trail likes * finalizes likes * fixes images for komoot * add disable federation option * adds private profiles * updates docs * adds federated comments * adds trail and comments actvitiypub routes * adds mentions to editor * adds mentions to trails, comments, summit logs * updates theme * updates theme * update docs * update docs * updates docs * fixes various frontend problems * fixes activitypub follows api * updates docs * updates docs --------- Co-authored-by: Christian Beutel <>
103 lines
2.8 KiB
Go
103 lines
2.8 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 {
|
|
collection, err := app.FindCollectionByNameOrId("j6w72f0kb5ivd7x")
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
|
|
return app.Delete(collection)
|
|
}, func(app core.App) error {
|
|
jsonData := `{
|
|
"createRule": null,
|
|
"deleteRule": null,
|
|
"fields": [
|
|
{
|
|
"autogeneratePattern": "",
|
|
"hidden": false,
|
|
"id": "text3208210256",
|
|
"max": 0,
|
|
"min": 0,
|
|
"name": "id",
|
|
"pattern": "^[a-z0-9]+$",
|
|
"presentable": false,
|
|
"primaryKey": true,
|
|
"required": true,
|
|
"system": true,
|
|
"type": "text"
|
|
},
|
|
{
|
|
"cascadeDelete": false,
|
|
"collectionId": "pbc_1295301207",
|
|
"hidden": false,
|
|
"id": "relation1148540665",
|
|
"maxSelect": 1,
|
|
"minSelect": 0,
|
|
"name": "actor",
|
|
"presentable": false,
|
|
"required": false,
|
|
"system": false,
|
|
"type": "relation"
|
|
},
|
|
{
|
|
"cascadeDelete": true,
|
|
"collectionId": "_pb_users_auth_",
|
|
"hidden": false,
|
|
"id": "_clone_kce8",
|
|
"maxSelect": 1,
|
|
"minSelect": 0,
|
|
"name": "user",
|
|
"presentable": false,
|
|
"required": false,
|
|
"system": false,
|
|
"type": "relation"
|
|
},
|
|
{
|
|
"hidden": false,
|
|
"id": "json2215181735",
|
|
"maxSize": 1,
|
|
"name": "followers",
|
|
"presentable": false,
|
|
"required": false,
|
|
"system": false,
|
|
"type": "json"
|
|
},
|
|
{
|
|
"hidden": false,
|
|
"id": "json1908379107",
|
|
"maxSize": 1,
|
|
"name": "following",
|
|
"presentable": false,
|
|
"required": false,
|
|
"system": false,
|
|
"type": "json"
|
|
}
|
|
],
|
|
"id": "j6w72f0kb5ivd7x",
|
|
"indexes": [],
|
|
"listRule": "@request.auth.id = user || (@collection.users_anonymous.id ?= user && @collection.users_anonymous.private ?= false)",
|
|
"name": "follow_counts",
|
|
"system": false,
|
|
"type": "view",
|
|
"updateRule": null,
|
|
"viewQuery": "SELECT \n (ROW_NUMBER() OVER()) as id,\n activitypub_actors.id as actor,\n activitypub_actors.user as user,\n COALESCE(followers.count, 0) AS followers,\n COALESCE(following.count, 0) AS following\nFROM activitypub_actors\nLEFT JOIN (\n SELECT followee AS actor_id, COUNT(*) AS count\n FROM follows\n GROUP BY followee\n) AS followers ON activitypub_actors.id = followers.actor_id\nLEFT JOIN (\n SELECT follower AS actor_id, COUNT(*) AS count\n FROM follows\n GROUP BY follower\n) AS following ON activitypub_actors.id = following.actor_id",
|
|
"viewRule": "@request.auth.id = user || (@collection.users_anonymous.id ?= user && @collection.users_anonymous.private ?= false)"
|
|
}`
|
|
|
|
collection := &core.Collection{}
|
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
|
return err
|
|
}
|
|
|
|
return app.Save(collection)
|
|
})
|
|
}
|