From 943bd827317a06a84f5b725b02d36a7c6b92f8cf Mon Sep 17 00:00:00 2001 From: Yaodong Yu <2814461814@qq.com> Date: Sat, 18 Feb 2023 10:58:14 +0800 Subject: [PATCH] feat: fix migrator_1_245_0_PR_1557.go (#1564) --- object/migrator_1_245_0_PR_1557.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/object/migrator_1_245_0_PR_1557.go b/object/migrator_1_245_0_PR_1557.go index 988b8b73..dbdaff46 100644 --- a/object/migrator_1_245_0_PR_1557.go +++ b/object/migrator_1_245_0_PR_1557.go @@ -38,8 +38,13 @@ func (*Migrator_1_245_0_PR_1557) DoMigration() *migrate.Migration { migration := migrate.Migration{ ID: "20230215organization--transfer phonePrefix to defaultCountryCode, countryCodes", Migrate: func(engine *xorm.Engine) error { + err := adapter.Engine.Sync2(new(Organization)) + if err != nil { + panic(err) + } + organizations := []*Organization{} - err := engine.Table("organization").Find(&organizations, &Organization{}) + err = engine.Table("organization").Find(&organizations, &Organization{}) if err != nil { panic(err) } @@ -55,7 +60,7 @@ func (*Migrator_1_245_0_PR_1557) DoMigration() *migrate.Migration { {Name: "Password", Visible: true, ViewRule: "Self", ModifyRule: "Self"}, {Name: "Email", Visible: true, ViewRule: "Public", ModifyRule: "Self"}, {Name: "Phone", Visible: true, ViewRule: "Public", ModifyRule: "Self"}, - {Name: "CountryCode", Visible: true, ViewRule: "Public", ModifyRule: "Admin"}, + {Name: "Country code", Visible: true, ViewRule: "Public", ModifyRule: "Admin"}, {Name: "Country/Region", Visible: true, ViewRule: "Public", ModifyRule: "Self"}, {Name: "Location", Visible: true, ViewRule: "Public", ModifyRule: "Self"}, {Name: "Affiliation", Visible: true, ViewRule: "Public", ModifyRule: "Self"}, @@ -75,7 +80,6 @@ func (*Migrator_1_245_0_PR_1557) DoMigration() *migrate.Migration { {Name: "WebAuthn credentials", Visible: true, ViewRule: "Self", ModifyRule: "Self"}, {Name: "Managed accounts", Visible: true, ViewRule: "Self", ModifyRule: "Self"}, } - sql := fmt.Sprintf("select phone_prefix from organization where owner='%s' and name='%s'", organization.Owner, organization.Name) results, _ := engine.Query(sql)