user_resources #100
Merged
Bezborodov
merged 10 commits from user_resources
into dev_mirocod
2 years ago
17 changed files with 216 additions and 24 deletions
@ -0,0 +1,28 @@ |
|||||||
|
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 |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue