From 605f10d3c896f821b6a09d0724523d580291bf24 Mon Sep 17 00:00:00 2001 From: Simon Martens Date: Tue, 11 Feb 2025 18:56:50 +0100 Subject: [PATCH] Better Indeces --- dbmodels/functions.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dbmodels/functions.go b/dbmodels/functions.go index 5ffee0e..0dfc706 100644 --- a/dbmodels/functions.go +++ b/dbmodels/functions.go @@ -26,7 +26,13 @@ func AddMusenalmIDIndex(collection *core.Collection) { func AddIndex(collection *core.Collection, field string, unique bool) { name := collection.Name - collection.AddIndex("idx_"+name+"_"+field, unique, field, "") + iname := "idx_" + name + "_" + field + u := "" + if unique { + u = "UNIQUE " + } + itext := "CREATE " + u + "INDEX " + iname + " ON " + name + " (" + field + " COLLATE NOCASE)" + collection.Indexes = append(collection.Indexes, itext) } func RelationTableName(collection1, collection2 string) string {