Rails influences iPhone Development - FMDB Migration Manager

While at day 3 of the iPhone Studio I was trying out the off topic and nice FMDB framework which is a SQLLite wrapper and abstracts some of the low level data type conversion. My first reaction was "Hey, we need migrations the Rails ways!"....and after some googling I stumbled upon the FMDB Migration Manager framework by Dr Nic. You can find more details in the README.

In short with that framework you can create several migrations that each look as follows:


@interface CreateStudents : FmdbMigration
{
}
@end
@implementation CreateStudents
- (void)up {
[self createTable:@"students" withColumns:[NSArray arrayWithObjects:
[FmdbMigrationColumn columnWithColumnName:@"first_name" columnType:@"string"],
[FmdbMigrationColumn columnWithColumnName:@"age" columnType:@"integer" defaultValue:21],
nil];
}
- (void)down {
[self dropTable:@"students"];
}
@end


That way the next time the application is updated the migration required to bring your application uptodate will be run. Cool. Note only can you add and remove columns but you can also run Objective-C code that will adapt the existing data to the required format for the new version.

Now I've gotta play with that framework.

Thanks guys for sharing this!

0 comments :: Rails influences iPhone Development - FMDB Migration Manager