MCPcopy Index your code
hub / github.com/TruthHun/BookStack / resetCategoryUniqueIndex

Function resetCategoryUniqueIndex

commands/install.go:36–54  ·  view source on GitHub ↗

删除分类中的title的唯一索引(兼容旧版本)

()

Source from the content-addressed store, hash-verified

34
35// 删除分类中的title的唯一索引(兼容旧版本)
36func resetCategoryUniqueIndex() {
37 var indexs []struct {
38 Table string `orm:"column(Table)"`
39 NonUnique int `orm:"column(Non_unique)"`
40 KeyName string `orm:"column(Key_name)"`
41 ColumnName string `orm:"column(Column_name)"`
42 }
43 showIndex := "SHOW INDEX FROM md_category"
44 dropIndex := "ALTER TABLE `md_category` DROP INDEX `%s`;"
45 addUniqueIndex := "ALTER TABLE `md_category` ADD UNIQUE( `pid`, `title`);"
46 o := orm.NewOrm()
47 o.Raw(showIndex).QueryRows(&indexs)
48 for _, index := range indexs {
49 if index.ColumnName == "title" {
50 o.Raw(fmt.Sprintf(dropIndex, index.KeyName)).Exec()
51 }
52 }
53 o.Raw(addUniqueIndex).Exec()
54}
55
56func Version() {
57 if len(os.Args) >= 2 && os.Args[1] == "version" {

Callers 1

InstallFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected