Artur Galyamov
2 years ago
7 changed files with 38 additions and 0 deletions
@ -0,0 +1,28 @@
|
||||
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_coordinate VARCHAR(20);", tableName) |
||||
_, err = engine.Exec(addColsQuery) |
||||
case schemas.SQLITE: |
||||
addColsQuery := fmt.Sprintf("ALTER TABLE \"%s\" ADD COLUMN location_coordinate TEXT;", tableName) |
||||
_, err = engine.Exec(addColsQuery) |
||||
case schemas.MYSQL: |
||||
addColsQuery := fmt.Sprintf("ALTER TABLE `%s` ADD COLUMN location_coordinate VARCHAR(20);", tableName) |
||||
_, err = engine.Exec(addColsQuery) |
||||
} |
||||
if err != nil { |
||||
return fmt.Errorf("Ошибка добавления колонок компетенции и ресурсы в проект: %v", err) |
||||
} else { |
||||
return nil |
||||
} |
||||
} |
Loading…
Reference in new issue