forked from pocketbase/pocketbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pocketbase#3790] added MaxSize json field option
- Loading branch information
1 parent
b9f391c
commit fb2eafe
Showing
42 changed files
with
247 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package migrations | ||
|
||
import ( | ||
"github.com/pocketbase/dbx" | ||
"github.com/pocketbase/pocketbase/daos" | ||
"github.com/pocketbase/pocketbase/models" | ||
"github.com/pocketbase/pocketbase/models/schema" | ||
) | ||
|
||
// Update all collections with json fields to have a default MaxSize json field option. | ||
func init() { | ||
AppMigrations.Register(func(db dbx.Builder) error { | ||
dao := daos.New(db) | ||
|
||
// note: update even the view collections to prevent | ||
// unnecessary change detections during the automigrate | ||
collections := []*models.Collection{} | ||
if err := dao.CollectionQuery().All(&collections); err != nil { | ||
return err | ||
} | ||
|
||
for _, collection := range collections { | ||
var needSave bool | ||
|
||
for _, f := range collection.Schema.Fields() { | ||
if f.Type != schema.FieldTypeJson { | ||
continue | ||
} | ||
|
||
options, _ := f.Options.(*schema.JsonOptions) | ||
if options != nil { | ||
options = &schema.JsonOptions{} | ||
} | ||
options.MaxSize = 5242880 // 5mb | ||
f.Options = options | ||
needSave = true | ||
} | ||
|
||
if !needSave { | ||
continue | ||
} | ||
|
||
// save only the collection model without updating its records table | ||
if err := dao.Save(collection); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
}, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
ui/dist/assets/AuthMethodsDocs-cb636f39.js → ui/dist/assets/AuthMethodsDocs-648abb0e.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
ui/dist/assets/AuthRefreshDocs-72e74bf1.js → ui/dist/assets/AuthRefreshDocs-a828e8e8.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ist/assets/AuthWithOAuth2Docs-03a42751.js → ...ist/assets/AuthWithOAuth2Docs-892682be.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.