HELP! Blob in database

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

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

You could always look at

ActiveRecord::Base.connection.adapter_name

and use a conditional to decide which parameter to pass.