Search code examples
sqlruby-on-railsherokurakescheduled-tasks

unable to migrate database on production while running rake task


i am developing a small app which will download a csv file(from a give url) everyday and inject the data(in csv file) to database and load the same data in the webview. its working perfect in my local system.but when i deployed to heroku database injection from csv file is not working.

here is my code.

downloader.rake file

namespace :downloader do
desc "download a file"
task:downloading => :environment do
Rails.logger.info("message from task")
Download.destroy_all
ActiveRecord::Base.connection.execute("DELETE from sqlite_sequence where name = 'downloads'")
#**********some other code ************
end
end

schedule.rb file

set :environment, 'production'

every 1.minutes do
rake "downloader:downloading"
end

when i run it in production it shows in log($tail -f log/production.log)

D, [2015-07-21T12:17:02.910529 #11740] DEBUG -- :   Download Load (0.2ms)  SELECT "downloads".* FROM "downloads"
E, [2015-07-21T12:17:02.910635 #11740] ERROR -- : SQLite3::SQLException: no such table: downloads: SELECT "downloads".* FROM "downloads"

Solution

  • Looks like your database is not ready on Heroku.

    Please veryify to have installed a mysql database for your application and then run heroku run db:setup to build the schema and seed it.