From cef7257ec8f0de87d420cb00a86a4862aa109cf4 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 8 Aug 2015 17:17:44 +0100 Subject: [PATCH] abstract unique index creation --- core/database.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/database.class.php b/core/database.class.php index 637e7c69..a00dc14c 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -238,9 +238,10 @@ class SQLite extends DBEngine { $extras = ""; foreach(explode(",", $data) as $bit) { $matches = array(); - if(preg_match("/INDEX\s*\((.*)\)/", $bit, $matches)) { - $col = $matches[1]; - $extras .= "CREATE INDEX {$name}_{$col} on {$name}({$col});"; + if(preg_match("/(UNIQUE)? ?INDEX\s*\((.*)\)/", $bit, $matches)) { + $uni = $matches[1]; + $col = $matches[2]; + $extras .= "CREATE $uni INDEX {$name}_{$col} ON {$name}({$col});"; } else { $cols[] = $bit;