heroku db:pull not working - ruby-on-rails

heroku db:pull postgresql://root:#localhost/db_name
After this command display this message
/usr/lib/ruby/gems/1.8/gems/rest-client-1.6.1/lib/restclient/abstract_response.rb:50: warning: parenthesize argument(s) for future version
Loaded Taps v0.3.13
Warning: Data in the database 'postgresql://root:#localhost/db_name' will be overwritten and will not be recoverable.
Are you sure you wish to continue? (y/n)? y
Failed to connect to database:
Sequel::AdapterNotFound -> LoadError: no such file to load -- sequel/adapters/postgresql
How to use db:pull

First, you need to fix your connection string: use postgres instead of postgresql.
You will need to have the pg db adapter installed to use Sequel's postgresql adapter:
gem install pg
You may also want to make sure your taps, sequel, and heroku gems are up to date:
gem install heroku taps sequel
Then try your heroku db:pull again. If that doesn't work, post a comment or hop in #heroku on Freenode and we can try to help.

Your connection string is wrong. Try:
heroku db:pull postgres://root:#localhost/db_name

Started working fine once I upgraded the "pg" gem from version "0.11.0" to "0.12.2".

Related

Rake assuming wrong database engine?

I have adapter set to "mysql2" in my database.yml, yet when I try to deploy to Heroku, I get an error telling me, that I don't have Postgres installed... What the heck?
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded.
Heroku works ONLY WITH POSTGRESQL
you should add postgresql to envirement what you use on Heroku
UPDATED
but Heroku has huck for MySQL:
TAKE A LOOK

sqlite3 won't go away....ruby on rails

I am trying to get rid of sqlite3 on my rails app and use postgres instead. I updated my gem file and removed it. manually uninstalled the sqlite3 gem. Got rid of it in my database.yml file. When I run rake db:create (As instructed on heroku) I get this:
db/development.sqlite3 already exists
I tried a whole bunch of rake commands and it continually refers to sqlite3. Why? I removed it? How do I remove it permanently from my app so I can go ahead and use postgres to deploy to heroku?
thank you so much itches head in mild frustration
This might be a sticky setting because spring is running. Did you try stopping spring?
spring stop

Thinking Sphinx mistakenly looks for mysql instead of postgresql

My database.yml file and my Gemfile specify the use of postgresql. However, when I run
rake ts:index
I get the error
rake aborted!
cannot load such file -- mysql2
Why is Thinking Sphinx looking for mysql?
mysql2 gem is required for connecting to Sphinx, so please include it even if you're using PostgreSQL as your database.
Reference:
https://github.com/pat/thinking-sphinx

Ruby on Rails - Heroku deployment issues

I seem to have reached a bump, searched here and on other foruns but nothing. I'm running rails 3.2.3 and ruby 1.9.3 and want to deploy my app on heroku.
I've created the cedar and although I can git push heroku master I am getting a complete 500 server error.
I suspect is it because my DB isn't there. However, I can't seem to get it there.
I've run:
heroku run rake db:create -> This gives out some warnings about deprecation and then dkhgclqccm already exists
So it exists already? So lets migrate it:
heroku run rake db:migrate
However this outputs:
<deprecation errors>
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::Error: ERROR: relation "hphotos" does not exist
: ALTER TABLE "hphotos" ADD COLUMN "description" character varying(255)
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
That particular migration is:
class AddDescriptionToHphotos < ActiveRecord::Migration
def change
add_column :hphotos, :description, :string
end
end
It seems good to me, don't know why its giving me this error :/
One Last thing, even if this migrations worked, my DB would be empty and me seeds.rb doesn't have all the necessary data for the database. So I though about pushing the hole DB.
heroku db:push
! Taps Load Error: cannot load such file -- sqlite3
! You may need to install or update the taps gem to use db commands.
! On most systems this will be:
!
! sudo gem install taps
Why is this showing?
I installed the 'heroku' gem and the 'taps' gem and I got this in my gem file:
group :development, :test do
gem 'mysql2'
end
group :production do
gem 'pg'
end
Also, when I run heroku run rake db:version, it shows: Current version: 20120508130957
This is actually 5 migrations short on my currrent version, but I can't migrate it as shows the error I spoke of above...
Thanks in advance
Heroku comes with a database set up (which is why db:create didn't work). have you tried heroku run rake db:schema:load? This should take your schema.rb file and load it up into the DB. This is a much better way of doing it than db:migrate every time you want to setup a new DB
Edit:
For your last question about taps, it looks like it's trying to use sqlite locally but you only have pg in your Gemfile. You probably have in config/database.yml adapter: sqlite. So either you need to use postgres locally and change that adapter to postgres, or go the easier route and use sqlite locally and add that to the :development group.
Note that heroku only uses postgres so I would not suggest developing off of mysql since there are some inconsistencies in some syntax and how you do a couple of things between the two platforms. Then again, if you're using only ANSI-compatible queries or just using rails' methods to activate queries then you should be ok either way.
I think you need to check your migrations closely to see if you actually have a file which says:
def up
create_table :hphotos do |t|
[...]
end
It seems that the table hasn't been created remotely and you are attempting to modify it.
The solution is to add not only taps gem but also sqlite3 gem into the Gemfile, into the :development group. If you are using sqlite3 in your development, then adding taps gem would be enough.
But since you are using mysql2 on your development so to solve that problem you have to add both.
group :development do
gem 'taps'
gem 'sqlite3'
end

Database issues with Heroku deployment

I've got a basic app that I'm trying to deploy to Heroku. I can push it to Heroku with git and it shows the default Rails welcome page, but when I try to access any subpages, (pages that work when I deploy on a local server with rails server) I get "something went wrong" messages.
I pulled up the log and I'm get 500 responses from the server and lots of ActiveRecord::ConnectionNotEstablished messages which seems to be an issue connecting to the database.
Further, when I tried to run heroku rake db:migrate, I get the following errors
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adap
ter` (pg is not part of the bundle. Add it to Gemfile.)
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)
Per the suggestion above, I did add gem 'pg' to the Gemfile After running gem install pg and then bundle install. Also, I tried gem install activerecord-postgresql-adapter (on Windows) and get
ERROR: Could not find a valid gem 'activerecord-postgresql-adapter' (>= 0) in a
ny repository
ERROR: Possible alternatives: activerecord-jdbcpostgresql-adapter, activerecord
-postgis-adapter, activerecord-jdbcmssql-adapter, activerecord-jdbcmysql-adapter
, activerecord-postgresql-cursors
From the suggestion of the book that I'm reading, I ran heroku db:push and it competed without error, but it didn't solve the problem of the pages not rendering once the app is push to Heroku.
update: I've tried installing the activerecord-jdbcpostgresql-adapter as suggested as a possible alternative. I updated the Gemfile with
group :production, :staging do
gem 'pg'
end
and the database.yml file with
production:
adapter: jdbcpostgresql
and when I heroku rake db:migrate, it still gives me the message telling me to install postgresql adapter
If heroku rake db:migrate runs without error, then your database connection info is correct. It's likely that there's another error preventing the page from rendering correctly. If you tail your heroku logs while making a request, are you still getting the same database error? I suspect that you'll find it's a different error that you'll need to fix.

Resources