Hi All,
My application saves a file into the database as blob. I am creating the
database table using rake migrate.
In postgresql it is working fine with :bytea type and on MySQL it is
working fine with :blob
I do not want to manually make changes except in database.yml
Can anybody help me with writing a more useful rake migrate code whichn
is more portable?
Thanks in advance.
Regards,
Janeve
Sample code:
=================For PostgreSQL:
------------------
class CreateActivities < ActiveRecord::Migration
def self.up
create_table :activities do |t|
t.column :a_file, :bytea
end
end
def self.down
drop_table :activities
end
End
=================For MySql:
------------------
class CreateActivities < ActiveRecord::Migration
def self.up
create_table :activities do |t|
t.column :a_file, :bytea
end
end
def self.down
drop_table :activities
end
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi,
Minor Change in the previous sample code.
Regards,
Janeve
Sample code:
=================For PostgreSQL:
------------------
class CreateActivities < ActiveRecord::Migration
def self.up
create_table :activities do |t|
t.column :a_file, :bytea
end
end
def self.down
drop_table :activities
end
End
=================For MySql:
------------------
class CreateActivities < ActiveRecord::Migration
def self.up
create_table :activities do |t|
t.column :a_file, :blob
end
end
def self.down
drop_table :activities
end
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
You could always look at ActiveRecord::Base.connection.adapter_name and use a conditional to decide which parameter to pass. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---