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
Related
I'm deploying small app from C9 to github then to Heroku!
In heroku deploy dashboard, it says it's been deployed, but when I open the app, it just gives me error msg.
So I searched a lot of Stackoverflow answers and was following the direction from Heroku website(https://devcenter.heroku.com/articles/sqlite3) to remove sqlite3 and install the gem pg.
I did replace gem 'sqlite3' to gem 'pg' and did 'bundle install', and then
It says I need to convert my config/database.yml file, So I replaced it like this:
development:
adapter: postgresql
database: my_database_development
pool: 5
timeout: 5000
test:
adapter: postgresql
database: my_database_test
pool: 5
timeout: 5000
production:
adapter: postgresql
database: my_database_production
pool: 5
timeout: 5000
and then when I come back to c9 bash and type 'rake db:create',
it shows me
**rake aborted!
ActiveRecord::NoDatabaseError: FATAL: database "my_database_development" does not exist**
this error.
someone said 'bundle exec rake db:setup' would work, so I did, and then it shows
**Couldn't create database for {"adapter"=>"postgresql", "database"=>"my_database_test", "pool"=>5, "timeout"=>5000}
/home/ubuntu/workspace/db/schema.rb doesn't exist yet. Run `rake db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ubuntu/workspace/config/application.rb to limit the frameworks that will be loaded.**
I don't know how to react to this msg.... when I type 'rake db:migrate' and it shows this again.
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: database "my_database_development" does not exist
I'm not using database, so maybe I can try something on 'config/application.rb' file, but how should I do??
It wasn't necessary to change your development and test databases, those could still have used sqlite3 and so your C9 instance would have continued to work.
(Although there are some advantages to using a consistent adapter across all environments)
If this is just a hobby exercise I would be tempted to keep sqlite3 for development and test.
Also, Heroku replaces the database.yml with its own version so you don't need a production stanza in database.yml
You do need the pg gem, but you can specify it is only loaded in production and you can specify the sqlite3 gem is only loaded in development and test. Do that in your Gemfile and then bundle.
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
If you want to use PostgreSQL in your C9 instance, you have to install PostgreSQL (the database, not just the adapter). It's not a simple process.
This wiki explains how you would install it.
https://wiki.postgresql.org/wiki/Detailed_installation_guides
one of the solution that you can create database manually this is easily solut
When I try to create a rails app on DigitalOcean (Ubuntu/Nginx/passenger) it always defaults to sqlite3 and I get an error message in the browser:
SQLite3::CantOpenException
But when I use WebBrick locally it works fine running on PostGres. What could be causing this and how can I get my app to use PostGres? It's installed on DigitalOcean and I can migrate and seed the database in my app, it just seems to want to use sqlite3. Any ideas?
The database configuration is in config/database.yml:
adapter: sqlite3
should be:
adapter: postgresql
Without seeing your database.yml I'd guess you have development setup with postgres but not production.
i have a remote SQLSERVER instance wich i want to connect from my rails app hosted on heroku.
My gemfile:
gem 'activerecord-sqlserver-adapter', '~> 3.2.12'
gem 'tiny_tds'
database.yml
production:
adapter: sqlserver
mode: dblib
dataserver: host.database.windows.net
database: items
username: username#host
password: password
azure: true
production.rb
dbconfig = YAML.load(ERB.new(File.read(File.join("config","database.yml"))).result)
ActiveRecord::Base.establish_connection dbconfig['production']
But i get the follwing error during the deploy process:
Writing config/database.yml to read from DATABASE_URL
Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
LoadError: Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.)
It seems that Active record require sqlite3 but if i have tiny_tds it should use sql server.
In development env all works fine.
Sure there is something i am missing.
UPDATE
I've already set up the custom buildpack
BUILDPACK_URL: https://github.com/firmhouse/heroku-buildpack-ruby-freetds.git
and the DATABASE_URL config var.
UPDATE 2
Making a pp of dbconfig var while deploing display this
{"production"=>
{"adapter"=>"sqlite3",
"database"=>"dbname",
"username"=>"user",
"password"=>"pass",
"host"=>"127.0.0.1"}}
It seems that heroku overwrite my database.yml file, any suggestions?
UPDATE 3
I have set DATABASE_URL=sqlserver//user:pass#host:1433/database is this wrong?
I've faced same issue and finally found the answer.
You have to put the suffix below:
?encoding=uft-8&azure=true
So, your database_url will be like this:
sqlserver://[user]:[password]#[server.database.windows.net]:1433/[database]?encoding=uft-8&azure=true
Hope it helps
Looks like you need to use a custom buildpack.
Using this FreeTDS buildpack on Heroku
To use this buildpack you can pass in an option when creating your Heroku app:
heroku create my_new_sqlserver_app --buildpack https://github.com/firmhouse/heroku-buildpack-ruby-freetds.git
Or for current apps:
heroku config:add BUILDPACK_URL=https://github.com/firmhouse/heroku-buildpack-ruby-freetds.git
Configuring your database connection
After creating your app or setting up your existing app to use the buildpack, you need to modify the DATABASE_URL config variable to point to your sqlserver instance. We currently use a SQL Server 2008 Express edition:
heroku config:add DATABASE_URL=sqlserver://username:password#sqlserver_host:1433/database_name
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
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".