Removing a limit from a binary column for PostgreSQL in datamapper

I am trying to create a binary field model in Datamapper for Rails 3 that looks like this:

class Image

  include DataMapper::Resource

  # attributes
  property :id, Serial
  property :url, String
  property :file_name, String
  property :content_type, String
  property :data, Binary
  property :created_at, DateTime
  property :updated_at, DateTime

end

However, when I try to migrate, I get the following:

ERROR:  type modifier is not allowed for type "bytea"
LINE 1: ..." VARCHAR(50), "content_type" VARCHAR(50), "data" BYTEA(50),...

I cannot find a way to remove the 50 limit that datamapper places on the field. Does anyone know how to do this or solve a problem?

+3
source share
1 answer

This is a bug in DataMapper. Check out this thread . It has already been fixed on GitHub, but has not yet reached the release. If you are ok with this, it is very easy to fix dm migrations to fix this. In "dm-migrations / adapters / dm-do-adapter.rb" you will find a line that says

if dump_class.equal?(String) && schema_primitive != 'TEXT' && schema_primitive != 'CLOB' && schema_primitive != 'NVARCHAR'

and add

&& schema_primitive != 'BYTEA'

to end.

, .

+4

All Articles