diff --git a/db/Dockerfile b/db/Dockerfile index dfc5390c..9d1f00e0 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -5,7 +5,7 @@ WORKDIR / COPY go.mod ./ COPY go.sum ./ -COPY pb_migrations ./pb_migrations +COPY migrations ./migrations RUN go mod download @@ -14,8 +14,8 @@ COPY *.go ./ RUN go build -o /pocketbase RUN /pocketbase migrate -ENV PUBLIC_MEILISEARCH_URL=http://localhost:7700 -ENV MEILISEARCH_MASTER_KEY= +ENV MEILI_URL=http://localhost:7700 +ENV MEILI_MASTER_KEY= EXPOSE 8090 diff --git a/db/main.go b/db/main.go index c883528d..9768cdb0 100644 --- a/db/main.go +++ b/db/main.go @@ -9,6 +9,9 @@ import ( "github.com/pocketbase/pocketbase" "github.com/pocketbase/pocketbase/core" "github.com/pocketbase/pocketbase/models" + "github.com/pocketbase/pocketbase/plugins/migratecmd" + + _ "pocketbase/migrations" ) func indexRecord(r *models.Record, client *meilisearch.Client) error { @@ -43,9 +46,14 @@ func indexRecord(r *models.Record, client *meilisearch.Client) error { func main() { app := pocketbase.New() + migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{ + Dir: "migrations", + Automigrate: true, + }) + client := meilisearch.NewClient(meilisearch.ClientConfig{ - Host: os.Getenv("PUBLIC_MEILISEARCH_URL"), - APIKey: os.Getenv("MEILISEARCH_MASTER_KEY"), + Host: os.Getenv("MEILI_URL"), + APIKey: os.Getenv("MEILI_MASTER_KEY"), }) app.OnRecordAfterCreateRequest("users").Add(func(e *core.RecordCreateEvent) error { diff --git a/db/migrations/1709593298_collections_snapshot.go b/db/migrations/1709593298_collections_snapshot.go new file mode 100644 index 00000000..dfbb4978 --- /dev/null +++ b/db/migrations/1709593298_collections_snapshot.go @@ -0,0 +1,665 @@ +package migrations + +import ( + "encoding/json" + + "github.com/pocketbase/dbx" + "github.com/pocketbase/pocketbase/daos" + m "github.com/pocketbase/pocketbase/migrations" + "github.com/pocketbase/pocketbase/models" +) + +func init() { + m.Register(func(db dbx.Builder) error { + jsonData := `[ + { + "id": "_pb_users_auth_", + "created": "2024-01-26 15:05:23.262Z", + "updated": "2024-02-29 16:52:40.743Z", + "name": "users", + "type": "auth", + "system": false, + "schema": [ + { + "system": false, + "id": "dlzhxcn2", + "name": "token", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + }, + { + "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 + } + }, + { + "system": false, + "id": "wjofulpg", + "name": "unit", + "type": "select", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "metric", + "imperial" + ] + } + }, + { + "system": false, + "id": "t1wlsqyp", + "name": "language", + "type": "select", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "en", + "de" + ] + } + }, + { + "system": false, + "id": "wosrk4ue", + "name": "location", + "type": "json", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSize": 2000000 + } + } + ], + "indexes": [], + "listRule": "id = @request.auth.id", + "viewRule": "id = @request.auth.id", + "createRule": "", + "updateRule": "id = @request.auth.id", + "deleteRule": "id = @request.auth.id", + "options": { + "allowEmailAuth": true, + "allowOAuth2Auth": true, + "allowUsernameAuth": true, + "exceptEmailDomains": null, + "manageRule": null, + "minPasswordLength": 8, + "onlyEmailDomains": null, + "onlyVerified": false, + "requireEmail": false + } + }, + { + "id": "e864strfxo14pm4", + "created": "2024-01-26 18:46:35.843Z", + "updated": "2024-02-23 12:47:30.327Z", + "name": "trails", + "type": "base", + "system": false, + "schema": [ + { + "system": false, + "id": "wquvuytd", + "name": "name", + "type": "text", + "required": true, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + }, + { + "system": false, + "id": "6kkucam1", + "name": "description", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + }, + { + "system": false, + "id": "8x74ba26", + "name": "location", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + }, + { + "system": false, + "id": "ehrmydva", + "name": "public", + "type": "bool", + "required": false, + "presentable": false, + "unique": false, + "options": {} + }, + { + "system": false, + "id": "epgmtyxy", + "name": "distance", + "type": "number", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": 0, + "max": null, + "noDecimal": false + } + }, + { + "system": false, + "id": "5wxdt3aj", + "name": "elevation_gain", + "type": "number", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "noDecimal": false + } + }, + { + "system": false, + "id": "ukr9rqz4", + "name": "duration", + "type": "number", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": 0, + "max": null, + "noDecimal": false + } + }, + { + "system": false, + "id": "eqeqja1s", + "name": "lat", + "type": "number", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "noDecimal": false + } + }, + { + "system": false, + "id": "y6dbfyw6", + "name": "lon", + "type": "number", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "noDecimal": false + } + }, + { + "system": false, + "id": "mcqce8l9", + "name": "thumbnail", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + }, + { + "system": false, + "id": "aqbpyawe", + "name": "photos", + "type": "file", + "required": false, + "presentable": false, + "unique": false, + "options": { + "mimeTypes": [ + "image/jpeg", + "image/vnd.mozilla.apng", + "image/png", + "image/webp", + "image/svg+xml" + ], + "thumbs": [], + "maxSelect": 99, + "maxSize": 5242880, + "protected": false + } + }, + { + "system": false, + "id": "k8xdrsyv", + "name": "gpx", + "type": "file", + "required": false, + "presentable": false, + "unique": false, + "options": { + "mimeTypes": [], + "thumbs": [], + "maxSelect": 1, + "maxSize": 5242880, + "protected": false + } + }, + { + "system": false, + "id": "b49obm5u", + "name": "category", + "type": "relation", + "required": false, + "presentable": false, + "unique": false, + "options": { + "collectionId": "kjxvi8asj2igqwf", + "cascadeDelete": false, + "minSelect": null, + "maxSelect": 1, + "displayFields": null + } + }, + { + "system": false, + "id": "1utgul91", + "name": "author", + "type": "relation", + "required": true, + "presentable": false, + "unique": false, + "options": { + "collectionId": "_pb_users_auth_", + "cascadeDelete": true, + "minSelect": null, + "maxSelect": 1, + "displayFields": null + } + }, + { + "system": false, + "id": "e1lwowvd", + "name": "summit_logs", + "type": "relation", + "required": false, + "presentable": false, + "unique": false, + "options": { + "collectionId": "dd2l9a4vxpy2ni8", + "cascadeDelete": false, + "minSelect": null, + "maxSelect": null, + "displayFields": null + } + }, + { + "system": false, + "id": "ppq2sist", + "name": "waypoints", + "type": "relation", + "required": false, + "presentable": false, + "unique": false, + "options": { + "collectionId": "goeo2ubp103rzp9", + "cascadeDelete": false, + "minSelect": null, + "maxSelect": null, + "displayFields": null + } + } + ], + "indexes": [], + "listRule": "author = @request.auth.id || public = true", + "viewRule": "author = @request.auth.id || public = true", + "createRule": "@request.auth.id != \"\" && (@request.data.author = @request.auth.id)", + "updateRule": "author = @request.auth.id ", + "deleteRule": "author = @request.auth.id ", + "options": {} + }, + { + "id": "kjxvi8asj2igqwf", + "created": "2024-01-26 18:47:30.797Z", + "updated": "2024-01-27 09:38:36.240Z", + "name": "categories", + "type": "base", + "system": false, + "schema": [ + { + "system": false, + "id": "38tbd8u4", + "name": "name", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + }, + { + "system": false, + "id": "64dsnxtb", + "name": "img", + "type": "file", + "required": false, + "presentable": false, + "unique": false, + "options": { + "mimeTypes": [], + "thumbs": [], + "maxSelect": 1, + "maxSize": 5242880, + "protected": false + } + } + ], + "indexes": [], + "listRule": "", + "viewRule": "", + "createRule": null, + "updateRule": null, + "deleteRule": null, + "options": {} + }, + { + "id": "goeo2ubp103rzp9", + "created": "2024-01-26 18:50:13.695Z", + "updated": "2024-02-04 11:49:30.732Z", + "name": "waypoints", + "type": "base", + "system": false, + "schema": [ + { + "system": false, + "id": "2yegzjtk", + "name": "name", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + }, + { + "system": false, + "id": "3xtcjtxv", + "name": "description", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + }, + { + "system": false, + "id": "ygotgxzy", + "name": "lat", + "type": "number", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "noDecimal": false + } + }, + { + "system": false, + "id": "q0ygnxd2", + "name": "lon", + "type": "number", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "noDecimal": false + } + }, + { + "system": false, + "id": "rnjgm2tk", + "name": "icon", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + } + ], + "indexes": [], + "listRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)", + "viewRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)", + "createRule": "@request.auth.id != \"\"", + "updateRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)", + "deleteRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)", + "options": {} + }, + { + "id": "dd2l9a4vxpy2ni8", + "created": "2024-01-27 12:23:48.069Z", + "updated": "2024-02-02 21:24:15.600Z", + "name": "summit_logs", + "type": "base", + "system": false, + "schema": [ + { + "system": false, + "id": "gxq1yeld", + "name": "date", + "type": "date", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": "", + "max": "" + } + }, + { + "system": false, + "id": "0ykzwuia", + "name": "text", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + } + ], + "indexes": [], + "listRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)", + "viewRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)", + "createRule": "@request.auth.id != \"\"", + "updateRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)", + "deleteRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)", + "options": {} + }, + { + "id": "r6gu2ajyidy1x69", + "created": "2024-02-27 11:46:07.367Z", + "updated": "2024-02-27 13:22:52.195Z", + "name": "lists", + "type": "base", + "system": false, + "schema": [ + { + "system": false, + "id": "0goi1ipa", + "name": "name", + "type": "text", + "required": true, + "presentable": false, + "unique": false, + "options": { + "min": 1, + "max": null, + "pattern": "" + } + }, + { + "system": false, + "id": "3v3pwnqn", + "name": "description", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + }, + { + "system": false, + "id": "decatj0h", + "name": "avatar", + "type": "file", + "required": false, + "presentable": false, + "unique": false, + "options": { + "mimeTypes": [ + "image/png", + "image/vnd.mozilla.apng", + "image/jpeg", + "image/webp", + "image/svg+xml" + ], + "thumbs": [], + "maxSelect": 1, + "maxSize": 5242880, + "protected": false + } + }, + { + "system": false, + "id": "jqtcrcnq", + "name": "trails", + "type": "relation", + "required": false, + "presentable": false, + "unique": false, + "options": { + "collectionId": "e864strfxo14pm4", + "cascadeDelete": false, + "minSelect": null, + "maxSelect": null, + "displayFields": null + } + }, + { + "system": false, + "id": "kwm6zdet", + "name": "author", + "type": "relation", + "required": false, + "presentable": false, + "unique": false, + "options": { + "collectionId": "_pb_users_auth_", + "cascadeDelete": false, + "minSelect": null, + "maxSelect": 1, + "displayFields": null + } + } + ], + "indexes": [], + "listRule": "author = @request.auth.id ", + "viewRule": "author = @request.auth.id ", + "createRule": "author = @request.auth.id ", + "updateRule": "author = @request.auth.id ", + "deleteRule": "author = @request.auth.id ", + "options": {} + } + ]` + + collections := []*models.Collection{} + if err := json.Unmarshal([]byte(jsonData), &collections); err != nil { + return err + } + + return daos.New(db).ImportCollections(collections, true, nil) + }, func(db dbx.Builder) error { + return nil + }) +} diff --git a/db/migrations/1709982456_updated_trails.go b/db/migrations/1709982456_updated_trails.go new file mode 100644 index 00000000..df214004 --- /dev/null +++ b/db/migrations/1709982456_updated_trails.go @@ -0,0 +1,74 @@ +package migrations + +import ( + "encoding/json" + + "github.com/pocketbase/dbx" + "github.com/pocketbase/pocketbase/daos" + m "github.com/pocketbase/pocketbase/migrations" + "github.com/pocketbase/pocketbase/models/schema" +) + +func init() { + m.Register(func(db dbx.Builder) error { + dao := daos.New(db); + + collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4") + if err != nil { + return err + } + + // remove + collection.Schema.RemoveField("mcqce8l9") + + // add + new_thumbnail := &schema.SchemaField{} + json.Unmarshal([]byte(`{ + "system": false, + "id": "k2giqyjq", + "name": "thumbnail", + "type": "number", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "noDecimal": false + } + }`), new_thumbnail) + collection.Schema.AddField(new_thumbnail) + + return dao.SaveCollection(collection) + }, func(db dbx.Builder) error { + dao := daos.New(db); + + collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4") + if err != nil { + return err + } + + // add + del_thumbnail := &schema.SchemaField{} + json.Unmarshal([]byte(`{ + "system": false, + "id": "mcqce8l9", + "name": "thumbnail", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + }`), del_thumbnail) + collection.Schema.AddField(del_thumbnail) + + // remove + collection.Schema.RemoveField("k2giqyjq") + + return dao.SaveCollection(collection) + }) +} diff --git a/db/pb_migrations/1706294795_created_trails.js b/db/pb_migrations/1706294795_created_trails.js deleted file mode 100644 index d27d06b9..00000000 --- a/db/pb_migrations/1706294795_created_trails.js +++ /dev/null @@ -1,71 +0,0 @@ -/// -migrate((db) => { - const collection = new Collection({ - "id": "e864strfxo14pm4", - "created": "2024-01-26 18:46:35.843Z", - "updated": "2024-01-26 18:46:35.843Z", - "name": "trails", - "type": "base", - "system": false, - "schema": [ - { - "system": false, - "id": "wquvuytd", - "name": "name", - "type": "text", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - }, - { - "system": false, - "id": "jjiidvbm", - "name": "thumbnail", - "type": "file", - "required": false, - "presentable": false, - "unique": false, - "options": { - "mimeTypes": [], - "thumbs": [], - "maxSelect": 1, - "maxSize": 5242880, - "protected": false - } - }, - { - "system": false, - "id": "6kkucam1", - "name": "description", - "type": "text", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - } - ], - "indexes": [], - "listRule": null, - "viewRule": null, - "createRule": null, - "updateRule": null, - "deleteRule": null, - "options": {} - }); - - return Dao(db).saveCollection(collection); -}, (db) => { - const dao = new Dao(db); - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4"); - - return dao.deleteCollection(collection); -}) diff --git a/db/pb_migrations/1706294826_updated_trails.js b/db/pb_migrations/1706294826_updated_trails.js deleted file mode 100644 index 15a71881..00000000 --- a/db/pb_migrations/1706294826_updated_trails.js +++ /dev/null @@ -1,33 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "k8xdrsyv", - "name": "gpx", - "type": "file", - "required": false, - "presentable": false, - "unique": false, - "options": { - "mimeTypes": [], - "thumbs": [], - "maxSelect": 1, - "maxSize": 5242880, - "protected": false - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // remove - collection.schema.removeField("k8xdrsyv") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706294850_created_categories.js b/db/pb_migrations/1706294850_created_categories.js deleted file mode 100644 index 591afb57..00000000 --- a/db/pb_migrations/1706294850_created_categories.js +++ /dev/null @@ -1,57 +0,0 @@ -/// -migrate((db) => { - const collection = new Collection({ - "id": "kjxvi8asj2igqwf", - "created": "2024-01-26 18:47:30.797Z", - "updated": "2024-01-26 18:47:30.797Z", - "name": "categories", - "type": "base", - "system": false, - "schema": [ - { - "system": false, - "id": "38tbd8u4", - "name": "name", - "type": "text", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - }, - { - "system": false, - "id": "64dsnxtb", - "name": "img", - "type": "file", - "required": false, - "presentable": false, - "unique": false, - "options": { - "mimeTypes": [], - "thumbs": [], - "maxSelect": 1, - "maxSize": 5242880, - "protected": false - } - } - ], - "indexes": [], - "listRule": null, - "viewRule": null, - "createRule": null, - "updateRule": null, - "deleteRule": null, - "options": {} - }); - - return Dao(db).saveCollection(collection); -}, (db) => { - const dao = new Dao(db); - const collection = dao.findCollectionByNameOrId("kjxvi8asj2igqwf"); - - return dao.deleteCollection(collection); -}) diff --git a/db/pb_migrations/1706294865_updated_trails.js b/db/pb_migrations/1706294865_updated_trails.js deleted file mode 100644 index 068ca559..00000000 --- a/db/pb_migrations/1706294865_updated_trails.js +++ /dev/null @@ -1,33 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "b49obm5u", - "name": "category", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "kjxvi8asj2igqwf", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": 1, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // remove - collection.schema.removeField("b49obm5u") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706295013_created_waypoints.js b/db/pb_migrations/1706295013_created_waypoints.js deleted file mode 100644 index a79ab94e..00000000 --- a/db/pb_migrations/1706295013_created_waypoints.js +++ /dev/null @@ -1,69 +0,0 @@ -/// -migrate((db) => { - const collection = new Collection({ - "id": "goeo2ubp103rzp9", - "created": "2024-01-26 18:50:13.695Z", - "updated": "2024-01-26 18:50:13.695Z", - "name": "waypoints", - "type": "base", - "system": false, - "schema": [ - { - "system": false, - "id": "2yegzjtk", - "name": "name", - "type": "text", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - }, - { - "system": false, - "id": "ygotgxzy", - "name": "lat", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "noDecimal": false - } - }, - { - "system": false, - "id": "q0ygnxd2", - "name": "lon", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "noDecimal": false - } - } - ], - "indexes": [], - "listRule": null, - "viewRule": null, - "createRule": null, - "updateRule": null, - "deleteRule": null, - "options": {} - }); - - return Dao(db).saveCollection(collection); -}, (db) => { - const dao = new Dao(db); - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9"); - - return dao.deleteCollection(collection); -}) diff --git a/db/pb_migrations/1706295108_updated_trails.js b/db/pb_migrations/1706295108_updated_trails.js deleted file mode 100644 index 629c0a1a..00000000 --- a/db/pb_migrations/1706295108_updated_trails.js +++ /dev/null @@ -1,39 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "aqbpyawe", - "name": "photos", - "type": "file", - "required": false, - "presentable": false, - "unique": false, - "options": { - "mimeTypes": [ - "image/jpeg", - "image/vnd.mozilla.apng", - "image/png", - "image/webp", - "image/svg+xml" - ], - "thumbs": [], - "maxSelect": 99, - "maxSize": 5242880, - "protected": false - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // remove - collection.schema.removeField("aqbpyawe") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706295171_updated_trails.js b/db/pb_migrations/1706295171_updated_trails.js deleted file mode 100644 index df1678cd..00000000 --- a/db/pb_migrations/1706295171_updated_trails.js +++ /dev/null @@ -1,92 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "jjiidvbm", - "name": "thumbnail", - "type": "file", - "required": false, - "presentable": false, - "unique": false, - "options": { - "mimeTypes": [ - "image/png", - "image/vnd.mozilla.apng", - "image/jpeg", - "image/webp", - "image/svg+xml" - ], - "thumbs": [], - "maxSelect": 1, - "maxSize": 5242880, - "protected": false - } - })) - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "k8xdrsyv", - "name": "gpx", - "type": "file", - "required": false, - "presentable": false, - "unique": false, - "options": { - "mimeTypes": [ - "application/gpx+xml" - ], - "thumbs": [], - "maxSelect": 1, - "maxSize": 5242880, - "protected": false - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "jjiidvbm", - "name": "thumbnail", - "type": "file", - "required": false, - "presentable": false, - "unique": false, - "options": { - "mimeTypes": [], - "thumbs": [], - "maxSelect": 1, - "maxSize": 5242880, - "protected": false - } - })) - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "k8xdrsyv", - "name": "gpx", - "type": "file", - "required": false, - "presentable": false, - "unique": false, - "options": { - "mimeTypes": [], - "thumbs": [], - "maxSelect": 1, - "maxSize": 5242880, - "protected": false - } - })) - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706295220_updated_trails.js b/db/pb_migrations/1706295220_updated_trails.js deleted file mode 100644 index b1e68c7d..00000000 --- a/db/pb_migrations/1706295220_updated_trails.js +++ /dev/null @@ -1,33 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "1utgul91", - "name": "author", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "_pb_users_auth_", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": 1, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // remove - collection.schema.removeField("1utgul91") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706344993_updated_trails.js b/db/pb_migrations/1706344993_updated_trails.js deleted file mode 100644 index cf77b2ba..00000000 --- a/db/pb_migrations/1706344993_updated_trails.js +++ /dev/null @@ -1,50 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "epgmtyxy", - "name": "distance", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": 0, - "max": null, - "noDecimal": false - } - })) - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "5wxdt3aj", - "name": "elevation_gain", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "noDecimal": false - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // remove - collection.schema.removeField("epgmtyxy") - - // remove - collection.schema.removeField("5wxdt3aj") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706345081_updated_trails.js b/db/pb_migrations/1706345081_updated_trails.js deleted file mode 100644 index 4d9f0c93..00000000 --- a/db/pb_migrations/1706345081_updated_trails.js +++ /dev/null @@ -1,44 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "wquvuytd", - "name": "name", - "type": "text", - "required": true, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "wquvuytd", - "name": "name", - "type": "text", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - })) - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706346024_updated_trails.js b/db/pb_migrations/1706346024_updated_trails.js deleted file mode 100644 index 73e1cad0..00000000 --- a/db/pb_migrations/1706346024_updated_trails.js +++ /dev/null @@ -1,31 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "8x74ba26", - "name": "location", - "type": "text", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // remove - collection.schema.removeField("8x74ba26") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706346152_updated_trails.js b/db/pb_migrations/1706346152_updated_trails.js deleted file mode 100644 index 5d303c84..00000000 --- a/db/pb_migrations/1706346152_updated_trails.js +++ /dev/null @@ -1,31 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ukr9rqz4", - "name": "time", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "noDecimal": false - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // remove - collection.schema.removeField("ukr9rqz4") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706347326_updated_trails.js b/db/pb_migrations/1706347326_updated_trails.js deleted file mode 100644 index 4c8e97c1..00000000 --- a/db/pb_migrations/1706347326_updated_trails.js +++ /dev/null @@ -1,44 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ukr9rqz4", - "name": "duration", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": 0, - "max": null, - "noDecimal": false - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ukr9rqz4", - "name": "time", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "noDecimal": false - } - })) - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706347629_updated_trails.js b/db/pb_migrations/1706347629_updated_trails.js deleted file mode 100644 index 3da64088..00000000 --- a/db/pb_migrations/1706347629_updated_trails.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.listRule = "" - collection.viewRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.listRule = null - collection.viewRule = null - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706348316_updated_categories.js b/db/pb_migrations/1706348316_updated_categories.js deleted file mode 100644 index ba8fcf0f..00000000 --- a/db/pb_migrations/1706348316_updated_categories.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("kjxvi8asj2igqwf") - - collection.listRule = "" - collection.viewRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("kjxvi8asj2igqwf") - - collection.listRule = null - collection.viewRule = null - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706358228_created_summit_book.js b/db/pb_migrations/1706358228_created_summit_book.js deleted file mode 100644 index b50db977..00000000 --- a/db/pb_migrations/1706358228_created_summit_book.js +++ /dev/null @@ -1,54 +0,0 @@ -/// -migrate((db) => { - const collection = new Collection({ - "id": "dd2l9a4vxpy2ni8", - "created": "2024-01-27 12:23:48.069Z", - "updated": "2024-01-27 12:23:48.069Z", - "name": "summit_book", - "type": "base", - "system": false, - "schema": [ - { - "system": false, - "id": "gxq1yeld", - "name": "date", - "type": "date", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": "", - "max": "" - } - }, - { - "system": false, - "id": "0ykzwuia", - "name": "text", - "type": "text", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - } - ], - "indexes": [], - "listRule": null, - "viewRule": null, - "createRule": null, - "updateRule": null, - "deleteRule": null, - "options": {} - }); - - return Dao(db).saveCollection(collection); -}, (db) => { - const dao = new Dao(db); - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8"); - - return dao.deleteCollection(collection); -}) diff --git a/db/pb_migrations/1706358242_updated_summit_book.js b/db/pb_migrations/1706358242_updated_summit_book.js deleted file mode 100644 index 1c46abee..00000000 --- a/db/pb_migrations/1706358242_updated_summit_book.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.name = "summit_log" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.name = "summit_book" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706358292_updated_trails.js b/db/pb_migrations/1706358292_updated_trails.js deleted file mode 100644 index 451d6b67..00000000 --- a/db/pb_migrations/1706358292_updated_trails.js +++ /dev/null @@ -1,54 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "e1lwowvd", - "name": "summit_logs", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "dd2l9a4vxpy2ni8", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": null, - "displayFields": null - } - })) - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ppq2sist", - "name": "waypoints", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "goeo2ubp103rzp9", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": null, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // remove - collection.schema.removeField("e1lwowvd") - - // remove - collection.schema.removeField("ppq2sist") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706358606_updated_waypoints.js b/db/pb_migrations/1706358606_updated_waypoints.js deleted file mode 100644 index 81051377..00000000 --- a/db/pb_migrations/1706358606_updated_waypoints.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "" - collection.viewRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = null - collection.viewRule = null - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706358614_updated_summit_log.js b/db/pb_migrations/1706358614_updated_summit_log.js deleted file mode 100644 index 1e3e4ad7..00000000 --- a/db/pb_migrations/1706358614_updated_summit_log.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.listRule = "" - collection.viewRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.listRule = null - collection.viewRule = null - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706358632_updated_summit_log.js b/db/pb_migrations/1706358632_updated_summit_log.js deleted file mode 100644 index 00babe84..00000000 --- a/db/pb_migrations/1706358632_updated_summit_log.js +++ /dev/null @@ -1,33 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "xwqncqng", - "name": "author", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "_pb_users_auth_", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": 1, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - // remove - collection.schema.removeField("xwqncqng") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706358670_updated_waypoints.js b/db/pb_migrations/1706358670_updated_waypoints.js deleted file mode 100644 index 82718312..00000000 --- a/db/pb_migrations/1706358670_updated_waypoints.js +++ /dev/null @@ -1,33 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "0fz9yp7c", - "name": "trail", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "e864strfxo14pm4", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": 1, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // remove - collection.schema.removeField("0fz9yp7c") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706358694_updated_summit_log.js b/db/pb_migrations/1706358694_updated_summit_log.js deleted file mode 100644 index c16766f3..00000000 --- a/db/pb_migrations/1706358694_updated_summit_log.js +++ /dev/null @@ -1,54 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - // remove - collection.schema.removeField("xwqncqng") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "b4zqrqpa", - "name": "trail", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "e864strfxo14pm4", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": 1, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "xwqncqng", - "name": "author", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "_pb_users_auth_", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": 1, - "displayFields": null - } - })) - - // remove - collection.schema.removeField("b4zqrqpa") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706358894_updated_waypoints.js b/db/pb_migrations/1706358894_updated_waypoints.js deleted file mode 100644 index fc3088c9..00000000 --- a/db/pb_migrations/1706358894_updated_waypoints.js +++ /dev/null @@ -1,33 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // remove - collection.schema.removeField("0fz9yp7c") - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "0fz9yp7c", - "name": "trail", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "e864strfxo14pm4", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": 1, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706358910_updated_summit_log.js b/db/pb_migrations/1706358910_updated_summit_log.js deleted file mode 100644 index 922c703d..00000000 --- a/db/pb_migrations/1706358910_updated_summit_log.js +++ /dev/null @@ -1,33 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - // remove - collection.schema.removeField("b4zqrqpa") - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "b4zqrqpa", - "name": "trail", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "e864strfxo14pm4", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": 1, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706359048_updated_waypoints.js b/db/pb_migrations/1706359048_updated_waypoints.js deleted file mode 100644 index 0681cbe3..00000000 --- a/db/pb_migrations/1706359048_updated_waypoints.js +++ /dev/null @@ -1,76 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ygotgxzy", - "name": "lat", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": 0, - "max": null, - "noDecimal": false - } - })) - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "q0ygnxd2", - "name": "lon", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": 0, - "max": null, - "noDecimal": false - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ygotgxzy", - "name": "lat", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "noDecimal": false - } - })) - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "q0ygnxd2", - "name": "lon", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "noDecimal": false - } - })) - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706359070_updated_waypoints.js b/db/pb_migrations/1706359070_updated_waypoints.js deleted file mode 100644 index dad825b6..00000000 --- a/db/pb_migrations/1706359070_updated_waypoints.js +++ /dev/null @@ -1,31 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "rnjgm2tk", - "name": "icon", - "type": "text", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // remove - collection.schema.removeField("rnjgm2tk") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706359428_updated_waypoints.js b/db/pb_migrations/1706359428_updated_waypoints.js deleted file mode 100644 index c79aedf0..00000000 --- a/db/pb_migrations/1706359428_updated_waypoints.js +++ /dev/null @@ -1,31 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "3xtcjtxv", - "name": "description", - "type": "text", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // remove - collection.schema.removeField("3xtcjtxv") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706529850_updated_trails.js b/db/pb_migrations/1706529850_updated_trails.js deleted file mode 100644 index 9746cbf1..00000000 --- a/db/pb_migrations/1706529850_updated_trails.js +++ /dev/null @@ -1,58 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // remove - collection.schema.removeField("jjiidvbm") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "mcqce8l9", - "name": "thumbnail", - "type": "text", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "jjiidvbm", - "name": "thumbnail", - "type": "file", - "required": false, - "presentable": false, - "unique": false, - "options": { - "mimeTypes": [ - "image/png", - "image/vnd.mozilla.apng", - "image/jpeg", - "image/webp", - "image/svg+xml" - ], - "thumbs": [], - "maxSelect": 1, - "maxSize": 5242880, - "protected": false - } - })) - - // remove - collection.schema.removeField("mcqce8l9") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706533600_updated_waypoints.js b/db/pb_migrations/1706533600_updated_waypoints.js deleted file mode 100644 index 4796117f..00000000 --- a/db/pb_migrations/1706533600_updated_waypoints.js +++ /dev/null @@ -1,76 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ygotgxzy", - "name": "lat", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "noDecimal": false - } - })) - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "q0ygnxd2", - "name": "lon", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "noDecimal": false - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ygotgxzy", - "name": "lat", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": 0, - "max": null, - "noDecimal": false - } - })) - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "q0ygnxd2", - "name": "lon", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": 0, - "max": null, - "noDecimal": false - } - })) - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706548284_updated_trails.js b/db/pb_migrations/1706548284_updated_trails.js deleted file mode 100644 index 382cc817..00000000 --- a/db/pb_migrations/1706548284_updated_trails.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.createRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.createRule = null - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706551417_updated_trails.js b/db/pb_migrations/1706551417_updated_trails.js deleted file mode 100644 index 093cb6b7..00000000 --- a/db/pb_migrations/1706551417_updated_trails.js +++ /dev/null @@ -1,84 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "e1lwowvd", - "name": "summit_logs", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "dd2l9a4vxpy2ni8", - "cascadeDelete": true, - "minSelect": null, - "maxSelect": null, - "displayFields": null - } - })) - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ppq2sist", - "name": "waypoints", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "goeo2ubp103rzp9", - "cascadeDelete": true, - "minSelect": null, - "maxSelect": null, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "e1lwowvd", - "name": "summit_logs", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "dd2l9a4vxpy2ni8", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": null, - "displayFields": null - } - })) - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ppq2sist", - "name": "waypoints", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "goeo2ubp103rzp9", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": null, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706552026_updated_waypoints.js b/db/pb_migrations/1706552026_updated_waypoints.js deleted file mode 100644 index 21c37336..00000000 --- a/db/pb_migrations/1706552026_updated_waypoints.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.createRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.createRule = null - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706552830_updated_trails.js b/db/pb_migrations/1706552830_updated_trails.js deleted file mode 100644 index 97b890aa..00000000 --- a/db/pb_migrations/1706552830_updated_trails.js +++ /dev/null @@ -1,84 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "e1lwowvd", - "name": "summit_logs", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "dd2l9a4vxpy2ni8", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": null, - "displayFields": null - } - })) - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ppq2sist", - "name": "waypoints", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "goeo2ubp103rzp9", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": null, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "e1lwowvd", - "name": "summit_logs", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "dd2l9a4vxpy2ni8", - "cascadeDelete": true, - "minSelect": null, - "maxSelect": null, - "displayFields": null - } - })) - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ppq2sist", - "name": "waypoints", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "goeo2ubp103rzp9", - "cascadeDelete": true, - "minSelect": null, - "maxSelect": null, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706552880_updated_summit_log.js b/db/pb_migrations/1706552880_updated_summit_log.js deleted file mode 100644 index 24e98f51..00000000 --- a/db/pb_migrations/1706552880_updated_summit_log.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.createRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.createRule = null - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706552897_updated_summit_log.js b/db/pb_migrations/1706552897_updated_summit_log.js deleted file mode 100644 index f3c7e51b..00000000 --- a/db/pb_migrations/1706552897_updated_summit_log.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.name = "summit_logs" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.name = "summit_log" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706553833_updated_trails.js b/db/pb_migrations/1706553833_updated_trails.js deleted file mode 100644 index 36368481..00000000 --- a/db/pb_migrations/1706553833_updated_trails.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.updateRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.updateRule = null - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706557823_updated_trails.js b/db/pb_migrations/1706557823_updated_trails.js deleted file mode 100644 index cd4ae5f8..00000000 --- a/db/pb_migrations/1706557823_updated_trails.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.deleteRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.deleteRule = null - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706558119_updated_waypoints.js b/db/pb_migrations/1706558119_updated_waypoints.js deleted file mode 100644 index 2427c307..00000000 --- a/db/pb_migrations/1706558119_updated_waypoints.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.updateRule = "" - collection.deleteRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.updateRule = null - collection.deleteRule = null - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706558125_updated_summit_logs.js b/db/pb_migrations/1706558125_updated_summit_logs.js deleted file mode 100644 index 2d993407..00000000 --- a/db/pb_migrations/1706558125_updated_summit_logs.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.updateRule = "" - collection.deleteRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.updateRule = null - collection.deleteRule = null - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706901300_updated_users.js b/db/pb_migrations/1706901300_updated_users.js deleted file mode 100644 index 9461dbcb..00000000 --- a/db/pb_migrations/1706901300_updated_users.js +++ /dev/null @@ -1,31 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("_pb_users_auth_") - - // remove - collection.schema.removeField("users_name") - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("_pb_users_auth_") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "users_name", - "name": "name", - "type": "text", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "pattern": "" - } - })) - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706905108_updated_trails.js b/db/pb_migrations/1706905108_updated_trails.js deleted file mode 100644 index b0e1d7b7..00000000 --- a/db/pb_migrations/1706905108_updated_trails.js +++ /dev/null @@ -1,27 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "ehrmydva", - "name": "public", - "type": "bool", - "required": false, - "presentable": false, - "unique": false, - "options": {} - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // remove - collection.schema.removeField("ehrmydva") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706905430_updated_trails.js b/db/pb_migrations/1706905430_updated_trails.js deleted file mode 100644 index a924fba6..00000000 --- a/db/pb_migrations/1706905430_updated_trails.js +++ /dev/null @@ -1,48 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "1utgul91", - "name": "author", - "type": "relation", - "required": true, - "presentable": false, - "unique": false, - "options": { - "collectionId": "_pb_users_auth_", - "cascadeDelete": true, - "minSelect": null, - "maxSelect": 1, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // update - collection.schema.addField(new SchemaField({ - "system": false, - "id": "1utgul91", - "name": "author", - "type": "relation", - "required": false, - "presentable": false, - "unique": false, - "options": { - "collectionId": "_pb_users_auth_", - "cascadeDelete": false, - "minSelect": null, - "maxSelect": 1, - "displayFields": null - } - })) - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706907701_updated_trails.js b/db/pb_migrations/1706907701_updated_trails.js deleted file mode 100644 index 451c78cb..00000000 --- a/db/pb_migrations/1706907701_updated_trails.js +++ /dev/null @@ -1,24 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.listRule = "author = @request.auth.id || public = true" - collection.viewRule = "author = @request.auth.id || public = true" - collection.createRule = "@request.auth.id != \"\" && (@request.data.author = @request.auth.id)" - collection.updateRule = "author = @request.auth.id " - collection.deleteRule = "author = @request.auth.id " - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.listRule = "" - collection.viewRule = "" - collection.createRule = "" - collection.updateRule = "" - collection.deleteRule = "" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706907926_updated_waypoints.js b/db/pb_migrations/1706907926_updated_waypoints.js deleted file mode 100644 index 53b9b3c5..00000000 --- a/db/pb_migrations/1706907926_updated_waypoints.js +++ /dev/null @@ -1,24 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.createRule = "@request.auth.id != \"\"" - collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)" - collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "" - collection.viewRule = "" - collection.createRule = "" - collection.updateRule = "" - collection.deleteRule = "" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706907953_updated_summit_logs.js b/db/pb_migrations/1706907953_updated_summit_logs.js deleted file mode 100644 index f18b2332..00000000 --- a/db/pb_migrations/1706907953_updated_summit_logs.js +++ /dev/null @@ -1,24 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.createRule = "@request.auth.id != \"\"" - collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)" - collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.listRule = "" - collection.viewRule = "" - collection.createRule = "" - collection.updateRule = "" - collection.deleteRule = "" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908030_updated_summit_logs.js b/db/pb_migrations/1706908030_updated_summit_logs.js deleted file mode 100644 index 1cb8ca1d..00000000 --- a/db/pb_migrations/1706908030_updated_summit_logs.js +++ /dev/null @@ -1,22 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)" - collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)" - collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908043_updated_waypoints.js b/db/pb_migrations/1706908043_updated_waypoints.js deleted file mode 100644 index 368e99a7..00000000 --- a/db/pb_migrations/1706908043_updated_waypoints.js +++ /dev/null @@ -1,22 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)" - collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)" - collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908165_updated_waypoints.js b/db/pb_migrations/1706908165_updated_waypoints.js deleted file mode 100644 index fc8af541..00000000 --- a/db/pb_migrations/1706908165_updated_waypoints.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\"" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908193_updated_waypoints.js b/db/pb_migrations/1706908193_updated_waypoints.js deleted file mode 100644 index 79f56578..00000000 --- a/db/pb_migrations/1706908193_updated_waypoints.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.viewRule = "@request.auth.id != \"\" " - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\"" - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908206_updated_waypoints.js b/db/pb_migrations/1706908206_updated_waypoints.js deleted file mode 100644 index ec9ae38b..00000000 --- a/db/pb_migrations/1706908206_updated_waypoints.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "@request.auth.id != \"\" " - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908221_updated_waypoints.js b/db/pb_migrations/1706908221_updated_waypoints.js deleted file mode 100644 index 1087c63f..00000000 --- a/db/pb_migrations/1706908221_updated_waypoints.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908229_updated_summit_logs.js b/db/pb_migrations/1706908229_updated_summit_logs.js deleted file mode 100644 index fa9d3725..00000000 --- a/db/pb_migrations/1706908229_updated_summit_logs.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.viewRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908236_updated_waypoints.js b/db/pb_migrations/1706908236_updated_waypoints.js deleted file mode 100644 index 1dd7eb43..00000000 --- a/db/pb_migrations/1706908236_updated_waypoints.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908260_updated_summit_logs.js b/db/pb_migrations/1706908260_updated_summit_logs.js deleted file mode 100644 index e255892b..00000000 --- a/db/pb_migrations/1706908260_updated_summit_logs.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.listRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908281_updated_waypoints.js b/db/pb_migrations/1706908281_updated_waypoints.js deleted file mode 100644 index 1087c63f..00000000 --- a/db/pb_migrations/1706908281_updated_waypoints.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908311_updated_waypoints.js b/db/pb_migrations/1706908311_updated_waypoints.js deleted file mode 100644 index 810d8d25..00000000 --- a/db/pb_migrations/1706908311_updated_waypoints.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id " - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908342_updated_waypoints.js b/db/pb_migrations/1706908342_updated_waypoints.js deleted file mode 100644 index 77d3a868..00000000 --- a/db/pb_migrations/1706908342_updated_waypoints.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id " - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908372_updated_waypoints.js b/db/pb_migrations/1706908372_updated_waypoints.js deleted file mode 100644 index 8ee07f24..00000000 --- a/db/pb_migrations/1706908372_updated_waypoints.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908432_updated_waypoints.js b/db/pb_migrations/1706908432_updated_waypoints.js deleted file mode 100644 index 66d85093..00000000 --- a/db/pb_migrations/1706908432_updated_waypoints.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "" - collection.viewRule = "" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908739_updated_trails.js b/db/pb_migrations/1706908739_updated_trails.js deleted file mode 100644 index 4589475f..00000000 --- a/db/pb_migrations/1706908739_updated_trails.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.viewRule = "" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.viewRule = "author = @request.auth.id || public = true" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908748_updated_trails.js b/db/pb_migrations/1706908748_updated_trails.js deleted file mode 100644 index 6b2df0c0..00000000 --- a/db/pb_migrations/1706908748_updated_trails.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.viewRule = "author = @request.auth.id || public = true" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - collection.viewRule = "" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908846_updated_waypoints.js b/db/pb_migrations/1706908846_updated_waypoints.js deleted file mode 100644 index 1a67deb0..00000000 --- a/db/pb_migrations/1706908846_updated_waypoints.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908854_updated_waypoints.js b/db/pb_migrations/1706908854_updated_waypoints.js deleted file mode 100644 index a3d8362a..00000000 --- a/db/pb_migrations/1706908854_updated_waypoints.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908926_updated_waypoints.js b/db/pb_migrations/1706908926_updated_waypoints.js deleted file mode 100644 index fb599ef9..00000000 --- a/db/pb_migrations/1706908926_updated_waypoints.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id " - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id " - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))" - collection.viewRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706908971_updated_waypoints.js b/db/pb_migrations/1706908971_updated_waypoints.js deleted file mode 100644 index ae2fde82..00000000 --- a/db/pb_migrations/1706908971_updated_waypoints.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id " - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id " - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id " - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id " - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706909005_updated_waypoints.js b/db/pb_migrations/1706909005_updated_waypoints.js deleted file mode 100644 index f42f4dca..00000000 --- a/db/pb_migrations/1706909005_updated_waypoints.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id " - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id " - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706909055_updated_summit_logs.js b/db/pb_migrations/1706909055_updated_summit_logs.js deleted file mode 100644 index 230676b3..00000000 --- a/db/pb_migrations/1706909055_updated_summit_logs.js +++ /dev/null @@ -1,22 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.listRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.viewRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)" - collection.updateRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)" - collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8") - - collection.listRule = "" - collection.viewRule = "" - collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)" - collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)" - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1706962342_updated_trails.js b/db/pb_migrations/1706962342_updated_trails.js deleted file mode 100644 index 8306c68b..00000000 --- a/db/pb_migrations/1706962342_updated_trails.js +++ /dev/null @@ -1,50 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "eqeqja1s", - "name": "lat", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "noDecimal": false - } - })) - - // add - collection.schema.addField(new SchemaField({ - "system": false, - "id": "y6dbfyw6", - "name": "lon", - "type": "number", - "required": false, - "presentable": false, - "unique": false, - "options": { - "min": null, - "max": null, - "noDecimal": false - } - })) - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("e864strfxo14pm4") - - // remove - collection.schema.removeField("eqeqja1s") - - // remove - collection.schema.removeField("y6dbfyw6") - - return dao.saveCollection(collection) -}) diff --git a/db/pb_migrations/1707047370_updated_waypoints.js b/db/pb_migrations/1707047370_updated_waypoints.js deleted file mode 100644 index 39b1b45b..00000000 --- a/db/pb_migrations/1707047370_updated_waypoints.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -migrate((db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)" - collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)" - - return dao.saveCollection(collection) -}, (db) => { - const dao = new Dao(db) - const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9") - - collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)" - collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)" - - return dao.saveCollection(collection) -}) diff --git a/docker-compose.yml b/docker-compose.yml index e69de29b..4c01635b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -0,0 +1,57 @@ +version: '3' + +x-common-env: &cenv + MEILI_URL: http://search:7700 + MEILI_MASTER_KEY: CHANGE_ME! + +services: + search: + image: getmeili/meilisearch:v1.6.2 + environment: + <<: *cenv + MEILI_NO_ANALYTICS: true + MEILI_HTTP_PAYLOAD_SIZE_LIMIT: 150 Mb + ports: + - 7700:7700 + networks: + - wanderer + volumes: + - ./data/data.ms:/meili_data/data.ms + restart: unless-stopped + + bootstrap: + build: ./search + environment: + <<: *cenv + depends_on: + search: + condition: service_started + networks: + - wanderer + db: + build: ./db + environment: + <<: *cenv + ports: + - "8090:8090" + networks: + - wanderer + restart: unless-stopped + volumes: + - ./data/pb_data:/pb_data + + web: + build: ./web + environment: + PUBLIC_MEILISEARCH_URL: http://localhost:7700 + PUBLIC_MEILISEARCH_API_TOKEN: + PUBLIC_POCKETBASE_URL: http://127.0.0.1:8090 + ports: + - "8080:3000" + networks: + - wanderer + restart: unless-stopped + +networks: + wanderer: + driver: bridge diff --git a/search/Dockerfile b/search/Dockerfile index 53caa74c..3c216ce4 100644 --- a/search/Dockerfile +++ b/search/Dockerfile @@ -1,13 +1,13 @@ FROM python:3.10-slim WORKDIR /app -COPY init.py /app +COPY bootstrap.py /app COPY cities500.tar.gz /app RUN tar -xvf cities500.tar.gz RUN pip install meilisearch==0.30.0 -ENV PUBLIC_MEILISEARCH_URL=http://localhost:7700 -ENV MEILISEARCH_MASTER_KEY= +ENV MEILI_URL=http://localhost:7700 +ENV MEILI_MASTER_KEY= -CMD ["python", "./init.py"] \ No newline at end of file +CMD ["python", "-u", "./bootstrap.py"] \ No newline at end of file diff --git a/search/bootstrap.py b/search/bootstrap.py new file mode 100644 index 00000000..8dbf75ba --- /dev/null +++ b/search/bootstrap.py @@ -0,0 +1,65 @@ +from meilisearch import Client +from meilisearch.errors import MeilisearchApiError +import json +import os + +MEILI_URL=os.getenv('MEILI_URL') +MEILI_MASTER_KEY=os.getenv('MEILI_MASTER_KEY') + +client = Client(MEILI_URL, MEILI_MASTER_KEY) + +def index_exists(index_name: str) -> bool: + try: + client.get_index(index_name) + return True + except MeilisearchApiError: + return False + +def init_indices(): + if not index_exists('cities500'): + print("Creating cities index...") + client.create_index('cities500', {'primaryKey': 'id'}) + + client.index('cities500').update_settings({ + 'sortableAttributes': ['_geo',], + 'filterableAttributes': ['_geo'] + }) + + print("Starting data import...") + json_file = open('cities500.json', encoding='utf-8') + cities = json.load(json_file) + + client.index('cities500').add_documents(cities) + print("Data import completed!") + + if not index_exists('trails'): + print("Creating trails index...") + client.create_index('trails', {'primaryKey': 'id'}) + + client.index('trails').update_settings({ + 'sortableAttributes': ['name', 'distance', 'elevation_gain', 'created',], + 'filterableAttributes': ['category', 'distance', 'elevation_gain', 'completed', '_geo', 'public', 'author'] + }) + + +def generate_public_token(): + search_key = client.get_keys().results[0] + + search_rules = { + 'trails': { + 'filter': 'public=true' + }, + 'cities500': {} + } + token = client.generate_tenant_token(api_key_uid=search_key.uid, search_rules=search_rules, api_key=search_key.key) + + return token + +print("Initializing indices...") +init_indices() +print("Indices initialized!") +token = generate_public_token() +print("Generating public token...") +print(f"PUBLIC_MEILISEARCH_API_TOKEN:{token}") + +print("Bootstrapping complete!") diff --git a/search/init.py b/search/init.py deleted file mode 100644 index f519b4d6..00000000 --- a/search/init.py +++ /dev/null @@ -1,44 +0,0 @@ -from meilisearch import Client -import json -import os - -PUBLIC_MEILISEARCH_URL=os.getenv('MEILISEARCH_URL') -MEILISEARCH_MASTER_KEY=os.getenv('MEILISEARCH_MASTER_KEY') - -client = Client(MEILISEARCH_URL, MEILISEARCH_MASTER_KEY) - -def init(): - client.create_index('cities500', {'primaryKey': 'id'}) - - client.index('cities500').update_settings({ - 'sortableAttributes': ['_geo',], - 'filterableAttributes': ['_geo'] - }) - - client.create_index('trails', {'primaryKey': 'id'}) - - client.index('trails').update_settings({ - 'sortableAttributes': ['name', 'distance', 'elevation_gain', 'created',], - 'filterableAttributes': ['category', 'distance', 'elevation_gain', 'completed', '_geo', 'public', 'author'] - }) - - - json_file = open('cities500.json', encoding='utf-8') - cities = json.load(json_file) - - client.index('cities500').add_documents(cities) - -def generate_public_token(): - search_key = client.get_keys().results[0] - - search_rules = { - 'trails': { - 'filter': 'public=true' - }, - 'cities500': {} - } - token = client.generate_tenant_token(api_key_uid=search_key.uid, search_rules=search_rules, api_key=search_key.key) - - print(token) - -generate_public_token() \ No newline at end of file diff --git a/web/src/hooks.server.ts b/web/src/hooks.server.ts index ba4491a8..bcc6303f 100644 --- a/web/src/hooks.server.ts +++ b/web/src/hooks.server.ts @@ -13,9 +13,12 @@ export const handle: Handle = async ({ event, resolve }) => { // validate the user existence and if the path is acceesible if (!pb.authStore.model && isRouteProtected(url.pathname)) { throw redirect(302, '/login'); + } else if (pb.authStore.model && url.pathname === "/login") { + throw redirect(302, '/'); } regenerateInstance(); + try { // get an up-to-date auth store state by verifying and refreshing the loaded auth model (if any) if (pb.authStore.isValid) { @@ -30,10 +33,10 @@ export const handle: Handle = async ({ event, resolve }) => { event.locals.user = pb.authStore.model const lang = pb.authStore.model?.language ?? event.request.headers.get('accept-language')?.split(',')[0] - - if (lang) { - locale.set(lang) - } + + if (lang) { + locale.set(lang) + } const response = await resolve(event) diff --git a/web/src/lib/components/list/list_card.svelte b/web/src/lib/components/list/list_card.svelte index b775e80e..ad668113 100644 --- a/web/src/lib/components/list/list_card.svelte +++ b/web/src/lib/components/list/list_card.svelte @@ -1,5 +1,6 @@ @@ -78,7 +74,7 @@
{#if previewURL.length > 0} avatar diff --git a/web/src/lib/components/list/list_select_modal.svelte b/web/src/lib/components/list/list_select_modal.svelte index 4186da3b..1514f1c5 100644 --- a/web/src/lib/components/list/list_select_modal.svelte +++ b/web/src/lib/components/list/list_select_modal.svelte @@ -6,6 +6,7 @@ import { trail } from "$lib/stores/trail_store"; import { _ } from "svelte-i18n"; import Modal from "../base/modal.svelte"; + import { getFileURL } from "$lib/util/file_util"; export let openModal: (() => void) | undefined = undefined; export let closeModal: (() => void) | undefined = undefined; @@ -42,7 +43,7 @@ {#if list.avatar} avatar {:else} diff --git a/web/src/lib/components/photo_card.svelte b/web/src/lib/components/photo_card.svelte index d6d3a975..ff71a467 100644 --- a/web/src/lib/components/photo_card.svelte +++ b/web/src/lib/components/photo_card.svelte @@ -26,7 +26,7 @@ > {/if}