Raw SQL in Migrations?

After reading AWDWR and searching the API, it appears the Rails’
implementation of Migrations has no way to execute a raw SQL
statement. True?

– gw

Greg -

On 9-Nov-07, at 2:31 PM, Greg W. wrote:

After reading AWDWR and searching the API, it appears the Rails’
implementation of Migrations has no way to execute a raw SQL
statement. True?

– gw

not true -

execute “insert into easy_as_pie …”

cheers,
Jodi

After reading AWDWR and searching the API, it appears the Rails’
implementation of Migrations has no way to execute a raw SQL
statement. True?

Simple, just use execute:

class MyMigration < ActiveRecord::Migration
def self.up
execute “alter table bar add constraint fk_bar_foo foreign key
(foo_id) references foo(id)”
end

def self.down
# …
end
end

On Nov 9, 2007, at 11:31 AM, Greg W. wrote:

After reading AWDWR and searching the API, it appears the Rails’
implementation of Migrations has no way to execute a raw SQL
statement. True?

Doh! Found it (in AWDWR not in the API docs). Funny, it uses the same
execute command that I opted for when I wrote a migrations framework
for Lasso :stuck_out_tongue:

– gw