OSDN Git Service

Cleanup compiler warning messages and alter backup & restore to handle new database...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / sql / DatabaseConnection.java
index 38f0e35..6d9eab6 100644 (file)
@@ -43,6 +43,7 @@ public class DatabaseConnection {
        private LinkedNotebookTable                     linkedNotebookTable;
        private SharedNotebookTable                     sharedNotebookTable;
        private SyncTable                                       syncTable;
+       private SystemIconTable                         systemIconTable;
        private final ApplicationLogger         logger;
        private Connection                                      conn;
        int id;
@@ -65,6 +66,7 @@ public class DatabaseConnection {
                syncTable = new SyncTable(logger, this);
                linkedNotebookTable = new LinkedNotebookTable(logger, this);
                sharedNotebookTable = new SharedNotebookTable(logger, this);
+               systemIconTable = new SystemIconTable(logger, this);
        }
        
        
@@ -140,29 +142,14 @@ public class DatabaseConnection {
                        Global.setDatabaseVersion(version);
                } 
                if (version.equals("0.86")) {
-/*                     sharedNotebookTable.dropTable();
-                       linkedNotebookTable.dropTable();
-                       
-                       executeSql("alter table notebook drop column publishingUri");
-                       executeSql("alter table notebook drop column publishingOrder");
-                       executeSql("alter table notebook drop column publishingAscending");
-                       executeSql("alter table notebook drop column publishingPublicDescription");
-                       executeSql("alter table notebook drop column stack");
-                       executeSql("alter table notebook drop column icon");
-                       executeSql("alter table tag drop column icon");
-                       executeSql("alter table SavedSearch drop column icon");
-                       
-                       executeSql("drop index NOTE_THUMBNAIL_INDEX;");
-                       executeSql("drop index NOTE_EXPUNGED_INDEX;");
-                       executeSql("drop index NOTE_DUEDATE_INDEX;");
-                       executeSql("drop index RESOURCES_GUID_INDEX;");
-*/             
+       
                        executeSql("alter table notebook add column publishingUri VarChar");
                        executeSql("alter table notebook add column publishingOrder Integer");
-                       executeSql("alter table notebook add column publishingAscending VarChar");
+                       executeSql("alter table notebook add column publishingAscending Boolean");
                        executeSql("alter table notebook add column publishingPublicDescription varchar");
                        executeSql("alter table notebook add column stack varchar");
                        executeSql("alter table notebook add column icon blob");
+                       executeSql("alter table notebook add column readOnly boolean");
                        executeSql("alter table tag add column icon blob");
                        executeSql("alter table SavedSearch add column icon blob");
 
@@ -171,11 +158,16 @@ public class DatabaseConnection {
                        executeSql("create index NOTE_DUEDATE_INDEX on note (attributeSubjectDate, guid);");
                        executeSql("create index RESOURCES_GUID_INDEX on noteresources (noteGuid, guid);");
                        executeSql("update note set thumbnailneeded=true, thumbnail=null;");
+                       executeSql("update notebook set publishingUri='', " +
+                                       "publishingAscending=false, stack='', readonly=false, publishingOrder=1, " +
+                                       "publishingPublicDescription=''");
                        
                        sharedNotebookTable.createTable();
                        linkedNotebookTable.createTable();
+                       systemIconTable.createTable();
                        
                        version = "0.95";
+                       executeSql("Insert into Sync (key, value) values ('FullNotebookSync', 'true')");
                        executeSql("Insert into Sync (key, value) values ('FullLinkedNotebookSync', 'true')");
                        executeSql("Insert into Sync (key, value) values ('FullSharedNotebookSync', 'true')");
                        Global.setDatabaseVersion(version);
@@ -204,7 +196,6 @@ public class DatabaseConnection {
        
        public void createTables() {
                Global.setDatabaseVersion("0.85");
-//             Global.setDatabaseVersion("0.95");
                Global.setAutomaticLogin(false);
                Global.saveCurrentNoteGuid("");
                Global.saveUploadAmount(0);
@@ -217,8 +208,7 @@ public class DatabaseConnection {
                watchFolderTable.createTable();
                invalidXMLTable.createTable();
                wordsTable.createTable();
-               syncTable.createTable();
-               
+               syncTable.createTable();                
        }
        
        public Connection getConnection() {
@@ -261,4 +251,7 @@ public class DatabaseConnection {
        public SharedNotebookTable getSharedNotebookTable() {
                return sharedNotebookTable;
        }
+       public SystemIconTable getSystemIconTable() {
+               return systemIconTable;
+       }
 }