Ruby migrations of plain SQL

Hi, we have tons of SQL scripts with CREATE this UPDATE that etc etc,
all nicely time stamped.
These are currently run manually, but I was thinking about writing a
tool to handle this, but first wanted to check if one existed already.

Basically it would have to work like Rails or Sequel migration does,
know which files have not been ran, and then run them in.

Does anyone know of a tool/gem that does this for plain/raw SQL files?

On Oct 23, 2012, at 04:49 , Ian V. [email protected] wrote:

Hi, we have tons of SQL scripts with CREATE this UPDATE that etc etc,
all nicely time stamped.
These are currently run manually, but I was thinking about writing a
tool to handle this, but first wanted to check if one existed already.

Basically it would have to work like Rails or Sequel migration does,
know which files have not been ran, and then run them in.

Does anyone know of a tool/gem that does this for plain/raw SQL files?

This wheel has been invented… Use activerecord or sequel and have the
.rb file run the raw sql.

Thanks for your reply, can you expand on how one could use AR or Sequel
to achieve this?

On Oct 23, 2012, at 13:26 , Ian V. [email protected] wrote:

Thanks for your reply, can you expand on how one could use AR or Sequel
to achieve this?

I’m pulling this out of my butt:

class RawSQL1 < ActiveRecord::Migration
def change
execute_sql File.read(“bogus.sql”)
end
end

which I would probably refactor to:

RawSQL1 = raw_execute “bogus.sql”

so that each file can be quickly generated from a simple rake task.