Today I was faced with an interesting dilemma, how does one programmatically define migrations into a plugin so you can essentially “plug-n-play”. I did a little bit of research into Rails Engines, and I wasn’t too terribly excited about the notion of having a dependency for such a small plugin, if this were something more integrated…I’d probably use it, but for this, I really only need to have these migrations run once you’ve installed the plugin, and be on my way.

So, I decided to do a little bit of research on the ActiveRecord::Migrator class to see how I could approach programmatically executing the migration outside of the standard rake task, so I could build my own custom migration rake task for my plugin.

It turns out, there are a bunch of functions you can utilize to build your own custom migration tasks for your plugin, that I wasn’t immediately aware of. Here is how I did it:

namespace :myplugin do
  desc "migrates my plugin's migration files into the database."
  task :migrate => :environment do
      ActiveRecord::Migrator.migrate(File.expand_path(File.dirname(__FILE__) + "/../db/migrate"))
      Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
  end
end

I simply saved that block of code into my plugin’s /tasks folder and named it custom_migration.rake. Next, I went to the root of my application and ran rake myplugin:migrate, and huzzah! it worked!

Nothing too amazing, and I actually based this entirely on the vanilla db:migrate function. The first line of the task essentially tells the ActiveRecord Migrator to search through my plugin’s db/migrate folder for any migration files it can find, and then brings all of them up! It would be nice if the vanilla db:migrate supported a MIGRATIONS_PATH constant so we could just use the same mechanics and build on top of them, rather than essentially re-write them just to do this.

OR better yet, wouldn’t it be nice if rails db:migrate actually scanned our plugins directory for migration files as well? That sounds like the best option to me.

Now, I am not sure if this is “the ruby way” to handle this problem, and as I stated earlier, Rails Engines is probably the way to go if you have a much larger plugin you are designing, but for me, this seemed to work just fine.

Limitations

There are some limitations to that custom task. For instance, if you were to run db:rollback, it would not be aware of the migration files that I have previously run that live within my plugin, you’d have to build another custom task to manage revoking the migrations you installed. Also, if they end up changing the way you actually migrate migrations, you might be screwed. But, alas, here is hoping for that MIGRATIONS_PATH constant!

I love my AppleTV. One of the coolest home entertainment systems I’ve played with, but unfortunately it does lack some pretty important functionality like being able to play DivX/XVid, any sort of file storage capabilities, and no way to surf the web or anything cool like that.

Well, it turns out, The good people over at Apple Core, LLC agree that these things were important and have created a nice utility for making these dreams a reality! Here are some of my favourite features:

It was easily one of the best $50 I’ve spent in a while. It creates a nice bootable USB stick, just restart the device and go! It has also not conflicted in any way with the other core functions of AppleTV, and yes, it works with the very latest firmware (2.1).

If you have an AppleTV, I definitely recommend this upgrade.

Wordpress has just released version 1.0 of their mobile blogging application for the iPhone. At first, the thought of blogging with any substance from my iPhone was kind of funny, but quite frankly, they’ve designed a tool that is awesome at doing just that.

One of the coolest things about it, is its ability to work with not only Wordpress blogs from wordpress.com, but ALSO custom installs! Thank you XML-RPC! You can also manage multiple blogs via the application.

You have the ability to write drafts, and save them locally to your iPhone, you can edit and manage drafts or previously published articles from your iPhone, and you can even take pictures on the fly and post them! How neat! One thing I wish it had that it does not, however, is the ability to manage comments. It’d be nice to be able to approve comments on the road if I needed to.

All in all, a must have if you are a Wordpress user, very impressed with this application!

The good peole at FiveRuns have just recently released a gem to the Ruby community that allows their ActiveRecord-managed data models to now have built-in sharding and/or replication functionality…with just a few lines of code!

What do I mean by Data Sharding? Read on:

Specifically we needed two features to scale our mysql database: application-level sharding and master/slave replication. Sharding is the process of splitting a dataset across many independent databases. This often happens based on geographical region (e.g. craigslist) or user account (e.g. flickr). Replication provides a near-real-time copy of a database which can be used for fault tolerance and to reduce load on the master node. Combined, you get a scalable database solution which does not require huge hardware to scale to huge volumes.

They call this new gem, DataFabric. DataFabric makes it super simple (and DRY) to make your application scales to multiple database shards, or even just provide basic replication to different database servers if you so choose.

For me, the idea of having something so complex as data sharding built into the core of ActiveRecord is absolutely fascinating! You don’t have to have any sort of mysql_proxy business, or other strange DRb services running in the background, just essentially plug and play.

Granted, I have not done a ton of personal research on this problem, but I have looked around a bit…anyhow, here is the problem:

My company is 100% Mac, except for our debian-based production environment. We are all running iCal to manage our milestones and meetings, but its really an adhoc solution, not as integrated as say…Exchange calendaring. I do know for a fact that there is an iCal Server, but I don’t really think its feasible to think I will be investing in an xserve + OS X server just to get my company a unified calendar.

Are there Unix-based solutions out there I can install on one of my Debian servers? I haven’t found anything very specific. I know that WebDav plays a part in all of this, is it just so elementary that there is no direct “solution” ?

Curious to see what others have done in this situation.