Problems with Postgres on Heroku

169 views
Skip to first unread message

David A McClain

unread,
Nov 29, 2009, 12:31:38 PM11/29/09
to DataMapper
Hello all,

I'm having a problem with DataMapper and Heroku. I'm sure it's more of
a Heroku problem than a DataMapper problem but maybe someone here can
help.

I have a Sinatra app that uses DataMapper. (I'm quite new to both
technologies.) It works fine in development but in production I'm
getting two annoying errors.

1. Heroku uses Postgres by default. DataMapper doesn't seem to be
setting the length of the columns. I'm getting errors on String and
Text. Postgres is complaining about them being varying(50). Well, Text
should be a Text column and String should be varying(150).

2. My db gets trashed after a while (when you visit the app after
Heroku spins down). By trashed I mean its gone. No database exists.

My code is

require 'rubygems'
require 'sinatra'
require 'dm-core'
require 'dm-timestamps'

configure :production do
DataMapper::setup(:default, ENV['DATABASE_URL'])
end

configure :development do
DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/languages.db")
DataMapper.auto_upgrade!
end


class Language
include DataMapper::Resource

property :id, Serial
property :name, String
property :used_for, Text
property :home_page, String, :length => 150
property :wiki, String, :length => 150
property :appeared, Integer
property :gist, Text
property :share_link, String
property :created_at, DateTime
property :updated_at, DateTime

end

Does anything here look out of place? Like I said, it all works
perfectly in development.

I also get these weird error messages from Heroku when I try to run
DataMapper.auto_migrate! and DateMapper.auto_upgrade!

>> DataMapper.auto_upgrade!
NoMethodError: undefined method `quote_value' for
#<DataObjects::Postgres::Connection:0x2b9748e7a260>


Thanks

David

David A McClain

unread,
Nov 30, 2009, 6:34:45 PM11/30/09
to DataMapper
UPDATE: This is resolved.

I contacted Heroku and they told me to add do_postgres to my required
gems.I did what I was told and everything seems to be "hunky-dory"
now.

Thanks

David
Reply all
Reply to author
Forward
0 new messages