I just finished converting our iOS app from TouchDB to CouchbaseLite. So 
far everything is working really well! 

There have been a couple of posts in this forum 
(https://groups.google.com/d/topic/mobile-couchbase/IUGxueNXTB8/discussion) 
about data conversion from TouchDB and CouchDB and I've found, as 
advertised, that CouchbaseLite indeed seems to happily read, write and sync 
our (test) users' old TouchDB database and documents just fine. 

However, I thought I'd highlight the one key must-do that I was only able 
to find in the response chain in that post: you must rename the "TouchDB" 
directory to "CouchbaseLite" or else CouchbaseLite will create a nice new 
empty directory and database(s), ignoring your users' existing data. In 
fact, you have to be sure to do this BEFORE you invoke [CBLManager 
sharedInstance] or it will be too late because the empty CouchbaseLite 
directory will already have been created.

Here is a method that I use before I invoke [CBLManager sharedInstance] 
(any fixes or enhancements are welcome):

// Rename the old TouchDB directory to the name CouchbaseLite expects.

-(void)renameOldDirectory {

    

    NSFileManager* fileManager = [NSFileManager defaultManager];

    

    // If old TouchDB directory exists rename to new CouchbaseLite name.

    NSArray *paths = NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory, NSUserDomainMask, YES);

    NSString* oldPath = [paths[0] stringByAppendingPathComponent:@"TouchDB"
];

    

    if ([fileManager fileExistsAtPath:oldPath]) {

        

        NSString *newPath = [paths[0] stringByAppendingPathComponent:
@"CouchbaseLite"];

        NSError *renameError = nil;

        [fileManager moveItemAtPath:oldPath toPath:newPath error
:&renameError];

        if (renameError) {

            NSLog(@"Error renaming TouchDB directory to CouchbaseLite %@", 
renameError.localizedDescription);

            // handle error

        }

    }

}

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/a207e59f-e86d-4410-b3e3-819084d62057%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to