Can’t add column in sqlite3 on Mac OS X 10.4

Mac OS X 10.4 ships with sqlite3 3.1.3 which apparently doesn’t support ALTER TABLE in order to add columns to existing tables. At least that was the explanation I found on why I couldn’t add a migration in a Rails project to add a column. Instead I got the following error when I ran “rake db:migrate”:

== 20081007233057 AddIngredientToRecipe: migrating ================================
-- add_column(:recipes, :ingredient_id, :integer)
rake aborted!
SQLite3::SQLException: near "ADD": syntax error: ALTER TABLE "recipes" ADD "ingredient_id" integer

To fix the problem I had to run “sudo gem install sqlite3-ruby”. Before I got that far, I upgraded my sqlite3 installtion to the latest version by compiling from source. I don’t know if that was actually necessary in order to solve the issue.