I am using pg for dev and test in local machine only
its in dev and test group out in gemfile
group :development, :test do
gem 'pg'
end
rails version is
Rails 3.0.19
ruby 1.8.7
I used moonshine or shorter cut of capistrano
capistrano:deploy
the migrations file can't be migrated using capistrano, throws an error.
I am trying to run migrations manually inside server
bundle exec rake db:migrate VERSION=20140205173759_add_hebrew_to_piles.rb
I have three files and wanted to run rake migrate on each one (got it from stackoverlow, rails run specific migration)
and got
no such file to load -- pg
I am using mysql as production database so I don't understand why is looking for pg inside my server? any help?
Related
I reset the database on Heroku in the database setting and ran heroku run rake db:migrate. Although it created all the data tables with correct columns per local database, it does not migrate any existing local data. Heroku database is just empty. In the past I ran the above code and worked fine but this time got stuck as shown below:
mac-a:skiny ran$ heroku run bundle exec rake db:migrate
Running bundle exec rake db:migrate on ⬢ blooming-citadel-66205... up, run.3076 (Hobby)
The PGconn, PGresult, and PGError constants are deprecated, and will be
removed as of version 1.0.
You should use PG::Connection, PG::Result, and PG::Error instead, respectively.
Called from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
ActiveRecord::SchemaMigration Load (1.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
As a note, I quit mac terminal while running heroku run rake db:reset and maybe there is some internal error...
Try to the following, edit your Gemfile like below
gem 'pg', '~> 0.20.0'
Or
gem 'pg', '~> 0.11'
Then bundle install and try, it's working on my hand.
Note: the tilde sign before the >, that's not a dash
Once you make this update in your group production of your Gemfile, ensure you run bundle install --without production (to update Gemfile.lock file), do a git add/commit cycle, then re-deploy to Heroku.
Hope it helps
Migrations are not supposed to create data. They define tables, indexes, constraints, etc.
You should use db:seed, after migrating, to create data (besides adding pg version as mentioned on other answer.)
Ruby 1.9.2 Rails 3.1
After the day of fighting with heroku issues I was able to finally have the command 'git push heroku master to work properly'.
Gemfile has proper enties and pg gem is installed
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
At this point application has been uploaded and start page can be viewed here http://growing-day-7939.heroku.com/
The next step should be migrating the database to the heroku with 'heroku rake db:migrate"
and it always fails.
c:\RailsInstaller\work\rfclub>heroku rake db:migrate
No app specified.
Run this command from an app folder or specify which app to use with --app <app name>
Other heroku commands fail with the same error as above - heroku ps, heroku logs, heroku config.
I've tried deleting and recreating the app, even tried creating the new heroku account and repeating the steps, but nothing seems to help.
Any ideas would be appreciated, I'm really stuck.
I think you'll need to deploy Rails 3.1 apps on Heroku's Cedar stack, via heroku create --stack cedar. The migration command will be heroku run rake db:migrate.
This problem was fixed in 0.9.8, but seems to have recurred in the 1.x branch.
In my Gemfile I have a group for the test and development environments that use the rspec gems.
On my production server rspec is not installed.
I used the command bundle install --without test development in my
rails app
Starting my rails app in production mode gives the exception:
Could not find gem 'rspec (>= 0)' in any of the gem sources listed in
your Gemfile.
If I comment out the test group the same error happens with the development group.
The same problem exists if I start in development mode, then it tries to load the gems in the test group.
It seems that bundler completely ignores the environment groups and tries to load all gems in Gemfile:
group :test do
gem "rspec"
end
group :development do
gem "rspec-rails"
end
versions:
bundle 1.0.15
rails 3.0.7
ruby 1.9.2-p180
I was having this problem too, the problem was that .bundle/config file had something like
"--without development test"
even tho I had never ran the bundle command with this parameters(maybe I cloned the repository from the Webbynode server and their system added this automatically for production...)
anyway, the fix was
rm .bundle/config
bundle install
I am trying to deploy to heroku.
Rails 3.1.0.rc4,
I get the following error from Heroku logs:
Starting process with command: `thin -p 48902 -e production -R /home/heroku_rack/heroku.ru start`
2011-06-20T11:25:44+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection': Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) (RuntimeError)
I tried to install the activerecord-postgresql-adapter but then I get this error:
Could not find gem 'activerecord-postgresql-adapter (>= 0)' in any of the gem sources listed in your Gemfile.
So I tried to add this to my gem file
gem 'pg'
which produced this error:
Installing pg (0.11.0) with native extensions /Users/imac/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
any ideas?
You don't have to install Postgres locally. In your Gemfile, put 'pg' in group :production, as johnny-grass suggests, and then when you run bundle, just specify --without production, like this:
bundle --without production
Unfortunately, you have to remember this argument when you run bundler, but at least you don't have to install and maintain postgres locally.
Please note that Heroku "strongly recommends against" using sqlite, saying that "Your production and development environment should be as close to identical as possible" http://devcenter.heroku.com/articles/rails3
Do you have PostgreSQL installed on your computer? If you don't then install it first, then install the pg gem.
# gemfile
group :production do
gem 'therubyracer-heroku', '0.8.1.pre3' # you will need this too
gem 'pg'
end
I found a solution in this Heroku article.
As Jared said, they suggest to create a different group for postgresql.
I am trying to get started with ruby on rails and whenever I try to start the server using rails server command I get the sqlite3 not found error. I tried the following:
which sqlite3
And I got the following:
/opt/local/bin/sqlite3
I am thinking that should it not be
/usr/local/bin/sqlite3
Why is it installed incorrectly on my machine? How can I fix it?
Check the output of gem list. If the sqlite gem is not in there then you need to install it.
For Rails 3 you need to add the following in your Gemfile:
gem 'sqlite'
... then run:
bundle install
For Rails 2 run:
gem install sqlite