ActiveRecord is available to you. Inside the self.up, you can do:

AnyArbitraryModel.connection.execute(all_of_your_sql)

Any model in your app will do, as you are bypassing your model's  
business rules and going directly to the connection. The return is a  
Mysql::Result, which you can look up here: http://www.tmtm.org/en/ruby/mysql/

Hope this helps.

On Apr 28, 2009, at 9:31 PM, Vipin wrote:

>
> Hi
>
> How can i combine multiple SQL statements into one place in self.up in
> a migration.
> For the following, method if i combine 3 SQL statements into one
> section I get the error.
>
> ######### following works fine
> def self.up
>      execute <<-EOF
>       CREATE TABLE pks (SNO TINYINT,BUSNO CHAR(20),EXPTIME TIME, PRIMARY
> KEY (SNO));
>      EOF
>      execute <<-EOF
> INSERT INTO pks (SNO,BUSNO,EXPTIME) VALUES('1','5L',080000);
>      EOF
>      execute <<-EOF
> INSERT INTO pks (SNO,BUSNO,EXPTIME) VALUES('2','5A',081500);
>      EOF
>
>  end
>
> ########## it doesn't work
>
> def self.up
>      execute <<-EOF
>       CREATE TABLE pks (SNO TINYINT,BUSNO CHAR(20),EXPTIME TIME, PRIMARY
> KEY (SNO));
> INSERT INTO pks (SNO,BUSNO,EXPTIME) VALUES('1','5L',080000);
> INSERT INTO pks (SNO,BUSNO,EXPTIME) VALUES('2','5A',081500);
>      EOF
>
>  end
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to