heroku db:push sqlite://mydatabase.db错误

时间:2013-01-21 13:42:45

标签: ruby sqlite heroku sinatra

**当我做" heroku db:push sqlite://mydatabase.db"我有Ruby + Sinatra + Sqlite3 + Heroku的问题:

当我这样做时:" heroku db:push sqlite://anotador.db"

控制台日志:

2013-01-21T12:37:11+00:00 app[web.1]: Errno::ENOENT - No such file or directory - /app/views/home.erb:
2013-01-21T12:37:11+00:00 app[web.1]:   /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:572:in `erb'

我的anotador.rb:

require 'rubygems'  
require 'sinatra'  
require 'data_mapper'

DataMapper::setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/anotador.db")  
class Nota  
  include DataMapper::Resource  
  property :id, Serial  
  property :content, Text, :required => true  
  property :complete, Boolean, :required => true, :default => false  
  property :created_at, DateTime  
  property :updated_at, DateTime  
end  
DataMapper.finalize.auto_upgrade! 

我的GemFile:

source :rubygems
gem 'sinatra'
gem 'data_mapper' 
gem 'rack-flash'
gem 'sinatra-redirect-with-flash'
gem 'builder'
gem 'dm-postgres-adapter', :group => :production
gem 'dm-sqlite-adapter', :group => :development
gem 'thin'

group :development, :test do
  gem 'sqlite3'
end
group :production do
  gem 'pg'
end

在命令行中:

$ bundle
$ git init 
$ git add .
$ git commit -m "comentario" 
$ heroku create nombreAPP --stack cedar
$ git push heroku master 

$ heroku addons:add heroku-postgresql:dev
$ heroku pg:promote <DATABASE_URL>  
$ heroku db:push sqlite://anotador.db 

我知道Heroku使用的是Postgres和SQLite

但是Heroku能够移动数据库并使用SQLite到Postgres这个链接中举例说明:

https://devcenter.heroku.com/articles/ruby #using-a-sql-database

我在开发和生产中使用sqlite3使用Postgres

在GemFile中:

group :development, :test do
  gem 'sqlite3'
end
group :production do
  gem 'pg'
end

此链接有一个例子:

http://yamilurbina.com/post/4854924459/deploying-a-sinatra-datamapper-sqlite-app-to-heroku

1 个答案:

答案 0 :(得分:1)

据我所知,你不能在Heroku上使用SQLite3。您可以使用Postgres或Mysql数据库。

所以当你说

heroku db:push sqlite://mydatabase.db

你不应该这样做。它不起作用,因为Herite上没有SQLite Gem。什么是db:push?这是一些佣金任务吗?我想你仍然需要将它指定给Heroku。