Платформа ЦРНП "Мирокод" для разработки проектов
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
967 B
28 lines
967 B
package migrations |
|
|
|
import ( |
|
"fmt" |
|
"xorm.io/xorm" |
|
"xorm.io/xorm/schemas" |
|
) |
|
|
|
func addTrustedPropsToRepo(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 competences TEXT, ADD COLUMN resources 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;", tableName, tableName) |
|
_, err = engine.Exec(addColsQuery) |
|
case schemas.MYSQL: |
|
addColsQuery := fmt.Sprintf("ALTER TABLE `%s` ADD COLUMN competences TEXT, ADD COLUMN resources TEXT;", tableName) |
|
_, err = engine.Exec(addColsQuery) |
|
} |
|
if err != nil { |
|
return fmt.Errorf("Ошибка добавления колонок компетенции и ресурсы в проект: %v", err) |
|
} else { |
|
return nil |
|
} |
|
}
|
|
|