Ruby on rails Heroku使用默认数据创建数据库

Ruby on rails Heroku使用默认数据创建数据库,ruby-on-rails,postgresql,sqlite,heroku,Ruby On Rails,Postgresql,Sqlite,Heroku,我是rails中的noobie,我对db有问题。My database.yml: development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000 test: adapter: sqlite3 database: db/test.sqlite3 pool: 5 timeout: 5

我是rails中的noobie,我对db有问题。My database.yml:

    development:
      adapter: sqlite3
      database: db/development.sqlite3
      pool: 5
      timeout: 5000

    test:
      adapter: sqlite3
      database: db/test.sqlite3
      pool: 5
      timeout: 5000

    production:
      adapter: sqlite3
      database: db/production.sqlite3
      pool: 5
      timeout: 5000
我成功地用这个填充了我的数据库

    namespace :db do
      desc "Erase and fill database"
      task :populate => :environment do
        require 'populator'
        require 'faker'

        [Country, Region, City, Turbaza].each(&:delete_all)

        ActiveRecord::Base.transaction do
          Country.populate 5 do |country|
            country.name = Faker::Address.country
            Region.populate 1..2 do |region|
              region.country_id = country.id
              region.name = Faker::Address.state
              City.populate 1..2 do |city|
                city.region_id = region.id
                city.name = Faker::Address.city
                Turbaza.populate 1..2 do |turbaza|
                  turbaza.city_id = city.id
                  turbaza.name = Populator.words(1..3).titleize
                end
              end
            end
          end
        end
      end
    end

因此,我的开发数据库中充满了数据,但我无法理解如何对生产数据库和数据库执行此操作。请,有人能帮我吗?

如果你已经将你的应用部署到Heroku中,你可以通过Heroku cli运行你的rake任务

p.S Heroku仅免费提供pg。所以我你想上传你的pg,我必须这样做

将gem“pg”添加到gem文件

bundle install 

commit you changes

rebuild your project in heroku

运行heroku run rake db:populate应该可以做到这一点,你试过了吗?(IMO)更好的解决方案是只使用seed()并运行
heroku run rake db:seed

谢谢!尝试了“heroku run rake db:populate”,结果成功了!
bundle install 

commit you changes

rebuild your project in heroku