1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-12-02 09:31:58 +02:00

skip empty automigrate templates

This commit is contained in:
Gani Georgiev
2022-12-02 11:36:13 +02:00
parent 6400924d29
commit d2028143df
3 changed files with 56 additions and 15 deletions

View File

@@ -17,6 +17,8 @@ const (
TemplateLangGo = "go"
)
var emptyTemplateErr = errors.New("empty template")
// -------------------------------------------------------------------
// JavaScript templates
// -------------------------------------------------------------------
@@ -271,6 +273,10 @@ func (p *plugin) jsDiffTemplate(new *models.Collection, old *models.Collection)
// -----------------------------------------------------------------
if len(upParts) == 0 && len(downParts) == 0 {
return "", emptyTemplateErr
}
up := strings.Join(upParts, "\n ")
down := strings.Join(downParts, "\n ")
@@ -646,6 +652,10 @@ func (p *plugin) goDiffTemplate(new *models.Collection, old *models.Collection)
}
// ---------------------------------------------------------------
if len(upParts) == 0 && len(downParts) == 0 {
return "", emptyTemplateErr
}
up := strings.Join(upParts, "\n\t\t")
down := strings.Join(downParts, "\n\t\t")
combined := up + down