Added nocollate indeces

This commit is contained in:
Simon Martens
2025-02-11 21:55:07 +01:00
parent 71dcf9bf5e
commit cda95c3958
5 changed files with 18 additions and 6 deletions

View File

@@ -21,7 +21,7 @@ func SetNotesAndAnnotationsField(fieldlist *core.FieldsList) {
}
func AddMusenalmIDIndex(collection *core.Collection) {
AddIndex(collection, MUSENALMID_FIELD, true)
AddIndexNoCollate(collection, MUSENALMID_FIELD, true)
}
func AddIndex(collection *core.Collection, field string, unique bool) {
@@ -35,6 +35,17 @@ func AddIndex(collection *core.Collection, field string, unique bool) {
collection.Indexes = append(collection.Indexes, itext)
}
func AddIndexNoCollate(collection *core.Collection, field string, unique bool) {
name := collection.Name
iname := "idx_" + name + "_" + field
u := ""
if unique {
u = "UNIQUE "
}
itext := "CREATE " + u + "INDEX " + iname + " ON " + name + " (" + field + ")"
collection.Indexes = append(collection.Indexes, itext)
}
func RelationTableName(collection1, collection2 string) string {
return "R_" + collection1 + "_" + collection2
}

View File

@@ -51,5 +51,5 @@ func agentsFields() core.FieldsList {
func agentsIndexes(collection *core.Collection) {
dbmodels.AddMusenalmIDIndex(collection)
dbmodels.AddIndex(collection, dbmodels.AGENTS_NAME_FIELD, false)
dbmodels.AddIndex(collection, dbmodels.URI_FIELD, false)
dbmodels.AddIndexNoCollate(collection, dbmodels.URI_FIELD, false)
}

View File

@@ -68,7 +68,7 @@ func itemsFields(app core.App) core.FieldsList {
func itemsIndexes(collection *core.Collection) {
dbmodels.AddIndex(collection, dbmodels.ITEMS_CONDITION_FIELD, false)
dbmodels.AddIndex(collection, dbmodels.ITEMS_OWNER_FIELD, false)
dbmodels.AddIndex(collection, dbmodels.ITEMS_LOCATION_FIELD, false)
dbmodels.AddIndex(collection, dbmodels.ITEMS_IDENTIFIER_FIELD, false)
dbmodels.AddIndex(collection, dbmodels.URI_FIELD, false)
dbmodels.AddIndexNoCollate(collection, dbmodels.ITEMS_LOCATION_FIELD, false)
dbmodels.AddIndexNoCollate(collection, dbmodels.ITEMS_IDENTIFIER_FIELD, false)
dbmodels.AddIndexNoCollate(collection, dbmodels.URI_FIELD, false)
}

View File

@@ -133,4 +133,5 @@ func partialsIndexes(collection *core.Collection) {
dbmodels.AddIndex(collection, dbmodels.PLACE_STMT_FIELD, false)
dbmodels.AddIndex(collection, dbmodels.PUBLICATION_STMT_FIELD, false)
dbmodels.AddIndex(collection, dbmodels.YEAR_FIELD, false)
dbmodels.AddIndexNoCollate(collection, dbmodels.ENTRIES_TABLE, false)
}

View File

@@ -35,7 +35,7 @@ func (p *IndexPage) Down(app core.App) error {
func (p *IndexPage) Setup(router *router.Router[*core.RequestEvent], app core.App, engine *templating.Engine) error {
router.GET("/{$}", func(e *core.RequestEvent) error {
var builder strings.Builder
err := engine.Render(&builder, "/", nil)
err := engine.Render(&builder, "/", nil, "blank")
if err != nil {
return err
}