mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 21:30:24 +08:00
feat: fix migrator_1_245_0_PR_1557.go (#1564)
This commit is contained in:
@ -38,8 +38,13 @@ func (*Migrator_1_245_0_PR_1557) DoMigration() *migrate.Migration {
|
|||||||
migration := migrate.Migration{
|
migration := migrate.Migration{
|
||||||
ID: "20230215organization--transfer phonePrefix to defaultCountryCode, countryCodes",
|
ID: "20230215organization--transfer phonePrefix to defaultCountryCode, countryCodes",
|
||||||
Migrate: func(engine *xorm.Engine) error {
|
Migrate: func(engine *xorm.Engine) error {
|
||||||
|
err := adapter.Engine.Sync2(new(Organization))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
organizations := []*Organization{}
|
organizations := []*Organization{}
|
||||||
err := engine.Table("organization").Find(&organizations, &Organization{})
|
err = engine.Table("organization").Find(&organizations, &Organization{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
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: "Password", Visible: true, ViewRule: "Self", ModifyRule: "Self"},
|
||||||
{Name: "Email", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
{Name: "Email", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
||||||
{Name: "Phone", 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: "Country/Region", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
||||||
{Name: "Location", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
{Name: "Location", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
||||||
{Name: "Affiliation", 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: "WebAuthn credentials", Visible: true, ViewRule: "Self", ModifyRule: "Self"},
|
||||||
{Name: "Managed accounts", 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)
|
sql := fmt.Sprintf("select phone_prefix from organization where owner='%s' and name='%s'", organization.Owner, organization.Name)
|
||||||
results, _ := engine.Query(sql)
|
results, _ := engine.Query(sql)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user