package migrations import ( "fmt" "xorm.io/xorm" "xorm.io/xorm/schemas" ) func addTrustedPropsToUser(engine *xorm.Engine) error { var err error tableName := "user" switch engine.Dialect().URI().DBType { case schemas.POSTGRES: addColsQuery := fmt.Sprintf("ALTER TABLE \"%s\" ADD COLUMN competences TEXT, ADD COLUMN resources TEXT, ADD COLUMN interests TEXT;", tableName) _, err = engine.Exec(addColsQuery) case schemas.SQLITE: addColsQuery := fmt.Sprintf("ALTER TABLE \"%s\" ADD COLUMN competences TEXT;\nALTER TABLE \"%s\" ADD COLUMN resources TEXT;\nALTER TABLE \"%s\" ADD COLUMN interests TEXT;", tableName, tableName, tableName) _, err = engine.Exec(addColsQuery) case schemas.MYSQL: addColsQuery := fmt.Sprintf("ALTER TABLE `%s` ADD COLUMN competences TEXT, ADD COLUMN resources TEXT, ADD COLUMN interests TEXT;", tableName) _, err = engine.Exec(addColsQuery) } if err != nil { return fmt.Errorf("Ошибка добавление колонок компетенций и тд: %v", err) } else { return nil } }