Платформа ЦРНП "Мирокод" для разработки проектов https://git.mirocod.ru
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
906 B

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