Платформа ЦРНП "Мирокод" для разработки проектов
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
1.0 KiB
28 lines
1.0 KiB
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 |
|
} |
|
}
|
|
|