_binary From dfae44863c78dfcfd20e705255f26c5c14621668 Mon Sep 17 00:00:00 2001
From: SalilShenoy <salilshenoy@gmail.com>
Date: Tue, 21 Nov 2017 13:01:42 -0800
Subject: [PATCH] Tweaks to the lexicon table adding limit to varchar and
 renaming column

---
 src/configs/Createdb.php         |  4 ++--
 src/library/VersionFunctions.php | 11 ++++++-----
 src/models/ProfileModel.php      |  4 ++++
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/configs/Createdb.php b/src/configs/Createdb.php
index 245836e6..07438d4a 100755
--- a/src/configs/Createdb.php
+++ b/src/configs/Createdb.php
@@ -269,7 +269,7 @@ foreach ($locales as $locale) {
             $count++;
             if ($count >= C\NUM_LEX_BULK_INSERTS) {
                 $insert_values = rtrim($insert_values, ',');
-                $query = "INSERT INTO LEXICON (WORD, LOCALE, POS) VALUES
+                $query = "INSERT INTO LEXICON (TERM, LOCALE, PART_SPEECH) VALUES
                     {$insert_values}";
                 $db->exec($query);
                 $insert_values = "";
@@ -278,7 +278,7 @@ foreach ($locales as $locale) {
         }
         if ($count > 0) {
             $insert_values = rtrim($insert_values, ',');
-            $query = "INSERT INTO LEXICON (WORD, LOCALE, POS) VALUES
+            $query = "INSERT INTO LEXICON (TERM, LOCALE, PART_SPEECH) VALUES
                 {$insert_values}";
             $db->exec($query);
         }
diff --git a/src/library/VersionFunctions.php b/src/library/VersionFunctions.php
index 67dc2a03..9ebe833b 100644
--- a/src/library/VersionFunctions.php
+++ b/src/library/VersionFunctions.php
@@ -1564,8 +1564,9 @@ function upgradeDatabaseVersion54(&$db)
  */
 function upgradeDatabaseVersion55(&$db)
 {
-    $db->execute("CREATE TABLE LEXICON(WORD VARCHAR, LOCALE VARCHAR,
-                POS VARCHAR, PRIMARY KEY(WORD, LOCALE))");
+    $db->execute("CREATE TABLE LEXICON(TERM VARCHAR(". C\LONG_NAME_LEN ."),
+        LOCALE VARCHAR(" . C\NAME_LEN . "),
+        PART_SPEECH VARCHAR, PRIMARY KEY(TERM, LOCALE))");
     // Retrieve the locales added to the Locale table
     $sql = "SELECT LOCALE_TAG from LOCALE";
     $result = $db->execute($sql);
@@ -1597,8 +1598,8 @@ function upgradeDatabaseVersion55(&$db)
                 $count++;
                 if ($count >= C\NUM_LEX_BULK_INSERTS) {
                     $insert_values = rtrim($insert_values, ',');
-                    $query = "INSERT INTO LEXICON (WORD, LOCALE, POS) VALUES
-                        {$insert_values}";
+                    $query = "INSERT INTO LEXICON (TERM, LOCALE, PART_SPEECH)
+                    VALUES {$insert_values}";
                     $db->exec($query);
                     $insert_values = "";
                     $count = 0;
@@ -1606,7 +1607,7 @@ function upgradeDatabaseVersion55(&$db)
             }
             if ($count > 0) {
                 $insert_values = rtrim($insert_values, ',');
-                $query = "INSERT INTO LEXICON (WORD, LOCALE, POS) VALUES
+                $query = "INSERT INTO LEXICON (TERM, LOCALE, PART_SPEECH) VALUES
                     {$insert_values}";
                 $db->exec($query);
             }
diff --git a/src/models/ProfileModel.php b/src/models/ProfileModel.php
index 3b31e613..887771f9 100755
--- a/src/models/ProfileModel.php
+++ b/src/models/ProfileModel.php
@@ -390,6 +390,10 @@ class ProfileModel extends Model
                 ACCESS_COUNT INTEGER,
                 PRIMARY KEY(ADDRESS, PAGE_NAME))",
             "VERSION" => "CREATE TABLE VERSION(ID INTEGER PRIMARY KEY)",
+            "LEXICON" => "CREATE TABLE LEXICON(
+                TERM VARCHAR(". C\LONG_NAME_LEN ."),
+                LOCALE VARCHAR(" . C\NAME_LEN . "),
+                PART_SPEECH VARCHAR, PRIMARY KEY(TERM, LOCALE))"
             ];
     }
     /**
-- 
2.15.0.windows.1

