diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 4e27af4d73..9036c4489b 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -375,6 +375,8 @@ var migrations = []Migration{ NewMigration("v208 was completely broken - remigrate", remigrateU2FCredentials), // v211 -> v212 NewMigration("add competences, resources, interests to user tbl", addTrustedPropsToUser), + // v212 -> v213 + NewMigration("add competences and resources to repo tbl", addTrustedPropsToRepo), } // GetCurrentDBVersion returns the current db version diff --git a/models/migrations/v212.go b/models/migrations/v212.go new file mode 100644 index 0000000000..bec9d021ea --- /dev/null +++ b/models/migrations/v212.go @@ -0,0 +1,28 @@ +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 + } +} diff --git a/models/repo/repo.go b/models/repo/repo.go index 5108231cd8..13108dfae8 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -100,6 +100,8 @@ type Repository struct { LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"` Name string `xorm:"INDEX NOT NULL"` Description string `xorm:"TEXT"` + Resources string `xorm:"TEXT"` + Competences string `xorm:"TEXT"` Website string `xorm:"VARCHAR(2048)"` OriginalServiceType api.GitServiceType `xorm:"index"` OriginalURL string `xorm:"VARCHAR(2048)"` diff --git a/options/locale/locale_ru-RU.ini b/options/locale/locale_ru-RU.ini index 4bc3f3faf8..f073f5997e 100644 --- a/options/locale/locale_ru-RU.ini +++ b/options/locale/locale_ru-RU.ini @@ -804,6 +804,8 @@ download_bundle=Скачать BUNDLE generate_repo=Создать проект generate_from=Создать из repo_desc=Описание +resources=Необходимые ресурсы +competences=Необходимые компетенции repo_desc_helper=Добавьте краткое описание (необязательно) repo_lang=Язык repo_gitignore_helper=Выберите шаблон .gitignore. diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index f0548aaffe..37dc4b3e99 100644 --- a/routers/web/repo/setting.go +++ b/routers/web/repo/setting.go @@ -151,6 +151,8 @@ func SettingsPost(ctx *context.Context) { repo.Name = newRepoName repo.LowerName = strings.ToLower(newRepoName) repo.Description = form.Description + repo.Resources = form.Resources + repo.Competences = form.Competences repo.Website = form.Website repo.IsTemplate = form.Template diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go index 550375bd7a..92cd82a1bf 100644 --- a/services/forms/repo_form.go +++ b/services/forms/repo_form.go @@ -115,6 +115,8 @@ func ParseRemoteAddr(remoteAddr, authUsername, authPassword string) (string, err type RepoSettingForm struct { RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"` Description string `binding:"MaxSize(255)"` + Resources string `binding:"MaxSize(1024)"` + Competences string `binding:"MaxSize(1024)"` Website string `binding:"ValidUrl;MaxSize(255)"` Interval string MirrorAddress string diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 2dc4ce17c6..f2adec149c 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -44,6 +44,14 @@ +