OSDN Git Service

Added inter-note links. Added index content controls. Altered Android Unicode test...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / sql / DatabaseConnection.java
index 0502657..d89ac43 100644 (file)
@@ -222,6 +222,10 @@ public class DatabaseConnection {
                        if (dbTableExists("NoteResources"))
                                executeSql("Drop table NoteResources;");
                }
+               if (!dbTableColumnExists("NOTE", "ORIGINAL_GUID")) {
+                       executeSql("alter table note add column ORIGINAL_GUID VarChar");
+                       executeSql("create index NOTE_ORIGINAL_GUID_INDEX on note (original_guid, guid);");
+               }
 
                
        }
@@ -356,4 +360,19 @@ public class DatabaseConnection {
         else
                return false;
        }
+       
+       //****************************************************************
+       //* Check if a row in a table exists
+       //****************************************************************
+       public boolean dbTableColumnExists(String tableName, String columnName) {
+        NSqlQuery query = new NSqlQuery(getConnection());
+        query.prepare("select TABLE_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME=:name and COLUMN_NAME=:column");
+        query.bindValue(":name", tableName.toUpperCase());
+        query.bindValue(":column", columnName);
+        query.exec();
+        if (query.next())
+               return true;
+        else
+               return false;
+       }
 }