Skip to content

Commit

Permalink
fix: fix autogenerated migration with surgical update and use collect…
Browse files Browse the repository at this point in the history
…ion name instead of id

- Run go mod tidy
  • Loading branch information
Dan6erbond committed May 4, 2023
1 parent c61994e commit 3afc79c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 deletions.
6 changes: 4 additions & 2 deletions server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ module github.com/Dan6erbond/share-me

go 1.19

require github.com/pocketbase/pocketbase v0.15.2
require (
github.com/pocketbase/dbx v1.10.0
github.com/pocketbase/pocketbase v0.15.2
)

require (
github.com/AlecAivazis/survey/v2 v2.3.6 // indirect
Expand Down Expand Up @@ -48,7 +51,6 @@ require (
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/pocketbase/dbx v1.10.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.7.0 // indirect
Expand Down
50 changes: 20 additions & 30 deletions server/migrations/1683208972_updated_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,36 @@ import (

func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
dao := daos.New(db)

collection, err := dao.FindCollectionByNameOrId("vnfvpvktvaivqe2")
collection, err := dao.FindCollectionByNameOrId("files")
if err != nil {
return err
}

// update
edit_file := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "zybfkrpp",
"name": "file",
"type": "file",
"required": false,
"unique": false,
"options": {
"maxSelect": 1,
"maxSize": 10737418240,
"mimeTypes": [
"image/jpeg",
"image/png",
"image/svg+xml",
"image/gif",
"image/webp",
"video/mp4"
],
"thumbs": [
"1200x630"
],
"protected": false
for _, f := range collection.Schema.Fields() {
if f.Name == "file" {
f.Options = &schema.FileOptions{
MaxSelect: 1,
MaxSize: 5242880,
MimeTypes: []string{
"image/jpeg",
"image/png",
"image/svg+xml",
"image/gif",
"image/webp",
"video/mp4",
},
Thumbs: []string{"1200x630"},
}
}
}`), edit_file)
collection.Schema.AddField(edit_file)
}

return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
dao := daos.New(db)

collection, err := dao.FindCollectionByNameOrId("vnfvpvktvaivqe2")
collection, err := dao.FindCollectionByNameOrId("files")
if err != nil {
return err
}
Expand Down

0 comments on commit 3afc79c

Please sign in to comment.