I've been trying to migrate my database to heroku, without success. I have added a few more users to my database and when trying to log them in with email address and password on my heroku app, I get invalid email/password error, even though this works perfectly fine on my local server. NO errors at all when doing all the steps described below.
As suggested in a previous post, I've tried the following:
bundle exec rake db:migrate
git add -A
git commit -m "Adding features"
git push heroku master
heroku run rake db:migrate
After I run this I get:
astelvida:~/workspace/sample_app (master) $ heroku run rake db:migrate
Running rake db:migrate on ⬢ shrouded-ravine-80000... up, run.2794
ActiveRecord::SchemaMigration Load (0.8ms)
SELECT "schema_migrations".* FROM "schema_migrations"
heroku restart
I've also checked my .sqlite3 file to check that the new users actually exist in the database.
I've also tried this: $ bundle exec rake db:migrate RAILS_ENV=production
I've also updated my gemfile.lock.
My gems in dev & production:
group :development, :test do
gem 'sqlite3', '1.3.9'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'puma', '3.1.0'
end
Note: I run bundle install --without production, however this is how I've always been using it, and the login data works for some of the users i've created in the past. Also I'm using rails 4.2.2.
Ok... let's get something clear here.
Rake db:migrate doesn't migrate the data of the database. It runs all migrations (Table creations, updates, etc) so that the database structure is the same, however the data isn't! It's a fresh new database with the same structure.
What you're doing is making sure your PG database has the same structure as your sqlite3 database and it does. But if you want to pass the data from one to another It's gonna be hard i would say. You have to create a dump file from your sqlite 3 database, change it to pg and run in your heroku app.
Here is a question about it.
Convert SQLITE SQL dump file to POSTGRESQL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With