Switch to automigrations
This commit is contained in:
parent
56acd63055
commit
362738f03a
12
main.go
12
main.go
|
@ -3,6 +3,8 @@ package main
|
|||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
_ "main/migrations"
|
||||
|
||||
|
@ -13,6 +15,7 @@ import (
|
|||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/plugins/migratecmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -22,6 +25,15 @@ func main() {
|
|||
|
||||
app := pocketbase.New()
|
||||
|
||||
// loosely check if it was executed using "go run"
|
||||
isGoRun := strings.HasPrefix(os.Args[0], os.TempDir())
|
||||
|
||||
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
|
||||
// enable auto creation of migration files when making collection changes in the Admin UI
|
||||
// (the isGoRun check is to enable it only during development)
|
||||
Automigrate: isGoRun,
|
||||
})
|
||||
|
||||
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
||||
e.Router.AddRoute(echo.Route{
|
||||
Method: http.MethodGet,
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/dbx"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
// add up queries...
|
||||
_, err := db.CreateUniqueIndex("stargazers", "unique_stargazers_on_user_tune", "user", "tune").Execute()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}, func(db dbx.Builder) error {
|
||||
// add down queries...
|
||||
_, err := db.DropIndex("stargazers", "unique_stargazers_on_user_tune").Execute()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
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": "9eif9v40b0uw9l8",
|
||||
"created": "2023-11-20 10:50:08.919Z",
|
||||
"updated": "2023-11-20 10:50:08.919Z",
|
||||
"name": "iniFiles",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "h9yfwmvx",
|
||||
"name": "signature",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 3,
|
||||
"max": 255,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "z3e1a5cl",
|
||||
"name": "file",
|
||||
"type": "file",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"mimeTypes": [
|
||||
"application/gzip",
|
||||
"application/octet-stream"
|
||||
],
|
||||
"thumbs": [],
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "t5uayom3",
|
||||
"name": "ecosystem",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"speeduino",
|
||||
"rusefi",
|
||||
"fome"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
"CREATE INDEX ` + "`" + `officialIniFiles_created_idx` + "`" + ` ON ` + "`" + `iniFiles` + "`" + ` (` + "`" + `created` + "`" + `)",
|
||||
"CREATE UNIQUE INDEX ` + "`" + `idx_unique_h9yfwmvx` + "`" + ` ON ` + "`" + `iniFiles` + "`" + ` (` + "`" + `signature` + "`" + `)"
|
||||
],
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("9eif9v40b0uw9l8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.DeleteCollection(collection)
|
||||
})
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
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": "z8cojwcvlyxxyll",
|
||||
"created": "2023-11-20 10:50:08.921Z",
|
||||
"updated": "2023-11-20 10:50:08.921Z",
|
||||
"name": "stargazers",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "him7pbq2",
|
||||
"name": "user",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ny7akrmn",
|
||||
"name": "tune",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "5djmpehuiigg06b",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
"CREATE INDEX ` + "`" + `_z8cojwcvlyxxyll_created_idx` + "`" + ` ON ` + "`" + `stargazers` + "`" + ` (` + "`" + `created` + "`" + `)",
|
||||
"CREATE UNIQUE INDEX ` + "`" + `unique_stargazers_on_user_tune` + "`" + ` ON ` + "`" + `stargazers` + "`" + ` (` + "`" + `user` + "`" + `, ` + "`" + `tune` + "`" + `)"
|
||||
],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z8cojwcvlyxxyll")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.DeleteCollection(collection)
|
||||
})
|
||||
}
|
|
@ -0,0 +1,446 @@
|
|||
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": "5djmpehuiigg06b",
|
||||
"created": "2023-11-20 10:50:08.921Z",
|
||||
"updated": "2023-11-20 10:50:08.921Z",
|
||||
"name": "tunes",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "io2qgnvc",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "pkq4wfcj",
|
||||
"name": "tuneId",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 5,
|
||||
"max": 255,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "6gd6tzwx",
|
||||
"name": "source",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"web",
|
||||
"app"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "jcjunqhl",
|
||||
"name": "signature",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 3,
|
||||
"max": 255,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "lwbwtgmx",
|
||||
"name": "stars",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "g9b17t9y",
|
||||
"name": "vehicleName",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 2,
|
||||
"max": 255,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "w7qssd4t",
|
||||
"name": "engineMake",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 2,
|
||||
"max": 255,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "h47ir1bi",
|
||||
"name": "engineCode",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 2,
|
||||
"max": 255,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "frqzy24e",
|
||||
"name": "displacement",
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "j1asw8n1",
|
||||
"name": "cylindersCount",
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 16,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "0x8poyze",
|
||||
"name": "aspiration",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"na",
|
||||
"turbocharged",
|
||||
"supercharged"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ssd9iccu",
|
||||
"name": "compression",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "whk0u6fg",
|
||||
"name": "fuel",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": 255,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "4ydhmn21",
|
||||
"name": "ignition",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": 255,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "lti2l0im",
|
||||
"name": "injectorsSize",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 100000,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "pmt4jrhm",
|
||||
"name": "year",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": 2222,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "s9fjthhs",
|
||||
"name": "hp",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 100000,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "s4csjkpt",
|
||||
"name": "stockHp",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 100000,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "hfpkctpl",
|
||||
"name": "readme",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 5,
|
||||
"max": 3000,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "dk22rxkw",
|
||||
"name": "tags",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"base map",
|
||||
"help needed"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "d5vpizsr",
|
||||
"name": "textSearch",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 1,
|
||||
"max": 2048,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "1bjweixt",
|
||||
"name": "visibility",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"public",
|
||||
"unlisted"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "roqbws6u",
|
||||
"name": "tuneFile",
|
||||
"type": "file",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"mimeTypes": [
|
||||
"application/gzip",
|
||||
"application/octet-stream"
|
||||
],
|
||||
"thumbs": [],
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "59syvgnj",
|
||||
"name": "customIniFile",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"mimeTypes": [
|
||||
"application/gzip",
|
||||
"application/octet-stream"
|
||||
],
|
||||
"thumbs": [],
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "gzccot0l",
|
||||
"name": "logFiles",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 5,
|
||||
"maxSize": 5242880,
|
||||
"mimeTypes": [
|
||||
"application/gzip",
|
||||
"application/octet-stream"
|
||||
],
|
||||
"thumbs": [],
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "2z0i9ttc",
|
||||
"name": "toothLogFiles",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 5,
|
||||
"maxSize": 5242880,
|
||||
"mimeTypes": [
|
||||
"application/gzip",
|
||||
"application/octet-stream"
|
||||
],
|
||||
"thumbs": [],
|
||||
"protected": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
"CREATE INDEX ` + "`" + `tunes_created_idx` + "`" + ` ON ` + "`" + `tunes` + "`" + ` (` + "`" + `created` + "`" + `)",
|
||||
"CREATE UNIQUE INDEX ` + "`" + `idx_unique_pkq4wfcj` + "`" + ` ON ` + "`" + `tunes` + "`" + ` (` + "`" + `tuneId` + "`" + `)"
|
||||
],
|
||||
"listRule": "visibility = \"public\" || (visibility = \"unlisted\" && author = @request.auth.id)",
|
||||
"viewRule": null,
|
||||
"createRule": "@request.auth.verified = true",
|
||||
"updateRule": "@request.auth.id = author",
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("5djmpehuiigg06b")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.DeleteCollection(collection)
|
||||
})
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
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"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = types.Pointer("")
|
||||
|
||||
collection.UpdateRule = types.Pointer("id = @request.auth.id && @request.data.verifiedAuthor = null")
|
||||
|
||||
collection.DeleteRule = nil
|
||||
|
||||
options := map[string]any{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"allowEmailAuth": true,
|
||||
"allowOAuth2Auth": true,
|
||||
"allowUsernameAuth": false,
|
||||
"exceptEmailDomains": null,
|
||||
"manageRule": null,
|
||||
"minPasswordLength": 8,
|
||||
"onlyEmailDomains": null,
|
||||
"requireEmail": true
|
||||
}`), &options)
|
||||
collection.SetOptions(options)
|
||||
|
||||
json.Unmarshal([]byte(`[
|
||||
"CREATE INDEX ` + "`" + `_systemprofiles0_created_idx` + "`" + ` ON ` + "`" + `users` + "`" + ` (` + "`" + `created` + "`" + `)"
|
||||
]`), &collection.Indexes)
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("users_name")
|
||||
|
||||
// add
|
||||
new_verifiedAuthor := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "fqmcoapu",
|
||||
"name": "verifiedAuthor",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}`), new_verifiedAuthor)
|
||||
collection.Schema.AddField(new_verifiedAuthor)
|
||||
|
||||
// update
|
||||
edit_avatar := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "users_avatar",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"mimeTypes": [
|
||||
"image/jpg",
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif"
|
||||
],
|
||||
"thumbs": null,
|
||||
"protected": false
|
||||
}
|
||||
}`), edit_avatar)
|
||||
collection.Schema.AddField(edit_avatar)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("id = @request.auth.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("id = @request.auth.id")
|
||||
|
||||
collection.UpdateRule = types.Pointer("id = @request.auth.id")
|
||||
|
||||
collection.DeleteRule = types.Pointer("id = @request.auth.id")
|
||||
|
||||
options := map[string]any{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"allowEmailAuth": true,
|
||||
"allowOAuth2Auth": true,
|
||||
"allowUsernameAuth": true,
|
||||
"exceptEmailDomains": null,
|
||||
"manageRule": null,
|
||||
"minPasswordLength": 8,
|
||||
"onlyEmailDomains": null,
|
||||
"requireEmail": false
|
||||
}`), &options)
|
||||
collection.SetOptions(options)
|
||||
|
||||
json.Unmarshal([]byte(`[]`), &collection.Indexes)
|
||||
|
||||
// add
|
||||
del_name := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "users_name",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), del_name)
|
||||
collection.Schema.AddField(del_name)
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("fqmcoapu")
|
||||
|
||||
// update
|
||||
edit_avatar := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "users_avatar",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
],
|
||||
"thumbs": null,
|
||||
"protected": false
|
||||
}
|
||||
}`), edit_avatar)
|
||||
collection.Schema.AddField(edit_avatar)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
156
pb_schema.json
156
pb_schema.json
|
@ -6,11 +6,13 @@
|
|||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "h9yfwmvx",
|
||||
"name": "signature",
|
||||
"type": "text",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 3,
|
||||
"max": 255,
|
||||
|
@ -18,11 +20,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "z3e1a5cl",
|
||||
"name": "file",
|
||||
"type": "file",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
|
@ -35,11 +39,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "t5uayom3",
|
||||
"name": "ecosystem",
|
||||
"type": "select",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
|
@ -68,11 +74,13 @@
|
|||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "pbfieldavatar",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
|
@ -88,11 +96,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "fqmcoapu",
|
||||
"name": "verifiedAuthor",
|
||||
"type": "bool",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}
|
||||
],
|
||||
|
@ -122,11 +132,13 @@
|
|||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "him7pbq2",
|
||||
"name": "user",
|
||||
"type": "relation",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "systemprofiles0",
|
||||
"cascadeDelete": false,
|
||||
|
@ -136,11 +148,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ny7akrmn",
|
||||
"name": "tune",
|
||||
"type": "relation",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "5djmpehuiigg06b",
|
||||
"cascadeDelete": false,
|
||||
|
@ -168,11 +182,13 @@
|
|||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "io2qgnvc",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "systemprofiles0",
|
||||
"cascadeDelete": false,
|
||||
|
@ -182,11 +198,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "pkq4wfcj",
|
||||
"name": "tuneId",
|
||||
"type": "text",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 5,
|
||||
"max": 255,
|
||||
|
@ -194,11 +212,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "6gd6tzwx",
|
||||
"name": "source",
|
||||
"type": "select",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
|
@ -208,11 +228,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "jcjunqhl",
|
||||
"name": "signature",
|
||||
"type": "text",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 3,
|
||||
"max": 255,
|
||||
|
@ -220,22 +242,27 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "lwbwtgmx",
|
||||
"name": "stars",
|
||||
"type": "number",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "g9b17t9y",
|
||||
"name": "vehicleName",
|
||||
"type": "text",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 2,
|
||||
"max": 255,
|
||||
|
@ -243,11 +270,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "w7qssd4t",
|
||||
"name": "engineMake",
|
||||
"type": "text",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 2,
|
||||
"max": 255,
|
||||
|
@ -255,11 +284,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "h47ir1bi",
|
||||
"name": "engineCode",
|
||||
"type": "text",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 2,
|
||||
"max": 255,
|
||||
|
@ -267,33 +298,41 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "frqzy24e",
|
||||
"name": "displacement",
|
||||
"type": "number",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 100
|
||||
"max": 100,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "j1asw8n1",
|
||||
"name": "cylindersCount",
|
||||
"type": "number",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 16
|
||||
"max": 16,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "0x8poyze",
|
||||
"name": "aspiration",
|
||||
"type": "select",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
|
@ -304,22 +343,27 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ssd9iccu",
|
||||
"name": "compression",
|
||||
"type": "number",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 100
|
||||
"max": 100,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "whk0u6fg",
|
||||
"name": "fuel",
|
||||
"type": "text",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": 255,
|
||||
|
@ -327,11 +371,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "4ydhmn21",
|
||||
"name": "ignition",
|
||||
"type": "text",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": 255,
|
||||
|
@ -339,55 +385,69 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "lti2l0im",
|
||||
"name": "injectorsSize",
|
||||
"type": "number",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 100000
|
||||
"max": 100000,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "pmt4jrhm",
|
||||
"name": "year",
|
||||
"type": "number",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": 2222
|
||||
"max": 2222,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "s9fjthhs",
|
||||
"name": "hp",
|
||||
"type": "number",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 100000
|
||||
"max": 100000,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "s4csjkpt",
|
||||
"name": "stockHp",
|
||||
"type": "number",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 100000
|
||||
"max": 100000,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "hfpkctpl",
|
||||
"name": "readme",
|
||||
"type": "text",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 5,
|
||||
"max": 3000,
|
||||
|
@ -395,11 +455,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "dk22rxkw",
|
||||
"name": "tags",
|
||||
"type": "select",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
|
@ -409,11 +471,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "d5vpizsr",
|
||||
"name": "textSearch",
|
||||
"type": "text",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 1,
|
||||
"max": 2048,
|
||||
|
@ -421,11 +485,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "1bjweixt",
|
||||
"name": "visibility",
|
||||
"type": "select",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
|
@ -435,11 +501,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "roqbws6u",
|
||||
"name": "tuneFile",
|
||||
"type": "file",
|
||||
"system": false,
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
|
@ -452,11 +520,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "59syvgnj",
|
||||
"name": "customIniFile",
|
||||
"type": "file",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
|
@ -469,11 +539,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "gzccot0l",
|
||||
"name": "logFiles",
|
||||
"type": "file",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 5,
|
||||
"maxSize": 5242880,
|
||||
|
@ -486,11 +558,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "2z0i9ttc",
|
||||
"name": "toothLogFiles",
|
||||
"type": "file",
|
||||
"system": false,
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 5,
|
||||
"maxSize": 5242880,
|
||||
|
|
Loading…
Reference in New Issue