我使用Heroku托管我的web应用程序,我有一个使用heroku run rake db:seed将用户推送到数据库的seeds.rb,但我目前有一个我不想覆盖的用户基线。是否可以使用这些用户创建一个seeds2.rb文件并运行heroku run rake db:seed,但使用seeds2.rb文件呢?(或者类似的东西)
自从我使用postgresql并将一个应用程序部署到Heroku上已经有一段时间了,我认为我在安装过程中犯了错误。
我已经在Heroku上创建了我的应用程序,有一个霍比开发数据库设置(I ran Heroku run rake db:setup)来设置我的数据库,但是我在database.yml文件中想知道我有错误吗?
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://gui
我想每天使用Heroku的重置我的数据库一次。
建议在调度程序中使用rake任务。这就是我尝试过的:
task :reset_database => :environment do
`heroku pg:reset MY_DB:URL`
`heroku run rake db:migrate db:seed`
# some other ruby commands
end
但是,我如何正确地做到这一点,因为将heroku命令放在backticks中(使用bash )在这里不起作用:
No such file or directory - heroku
我以前发过这个问题,但没有任何答案来解决我的问题。因此,我现在重贴这个问题。
我正在使用heroku部署我的rails应用程序。我试图通过运行命令heroku run rake db:seed.在生产中添加一些数据,但是该命令不起作用。我无法在生产中播撒文件。下面给出了seeds.rb文件。
#This file should contain all the record creation needed to seed the database with its default values.
#The data can then be loaded with the rake db:seed
当我尝试运行时:
heroku run rake db:drop db:create db:migrate
我得到了错误:
Running rake db:drop attached to terminal... up, run.5
Couldn't drop adsfsadfas : #<ActiveRecord::StatementInvalid: PGError: ERROR: must be owner of database adsfsadfas
: DROP DATABASE IF EXISTS "adsfsadfas">
我在Heroku雪松
我已经在heroku上创建了我的堆栈,所有的东西都已经部署好了,但是当我尝试通过URL实际访问它时,它只会默认到500.html错误页面。这个应用程序在我的本地主机上运行得很好,但我是用sqlite3开发的。此后,我更改了我的Gemfile,使其如下所示,并运行bundle install。
#gem 'sqlite3'
gem 'thin'
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
当你访问ur
我正在尝试将我的Rails应用程序推到Heroku,而且我正在尝试创建/迁移数据库,但我无法运行rake命令。我得到的信息如下:
$ heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.2439
bash: rake: command not found
我花了很多时间在我的本地机器上安装Postgres,它运行良好(能够运行rake命令,并且应用程序在本地运行),但我不知道为什么在迁移heroku数据库时会出现这个错误。
当我运行heroku run rake db:migrate时,我会得到这个错误:
rake aborted!
PG::Error: ERROR: relation "roles" does not exist
LINE 4: WHERE a.attrelid = '"roles"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod
一次疯狂(3.1)在当地工作。下一步是推到heroku。我肯定有postgresql。但似乎我必须使用类似的rails命令手动完成安装表。在中我应该运行
rails g spree:install --user_class=Spree::User
rails g spree:auth:install
rails g spree_gateway:install
我的第一个问题是如何为heroku运行这些命令。
我的解决方案是使用以下命令
heroku run rake spree:install --user_class=Spree::User
heroku
我正在使用postgresql,并且一直在本地dev环境下操作。我把我的应用程序部署到Heroku,现在我需要设置heroku来使用数据库,就像我在本地一样。
在当地,我会这样做:
rake db:create
rake db:migrate
在heroku上,我尝试了同样的方法:
heroku run rake db:create
但是,返回此错误:
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
Couldn't cre
我在使用FileUtils#sh的Rails 4应用程序中运行Rake命令时遇到了问题。我使用RVM作为版本管理器,但似乎找不到问题所在。我得到的错误是:
$ rake db:clone_production:to_local --trace
** Invoke db:clone_production:to_local (first_time)
** Execute db:clone_production:to_local heroku pgbackups:capture --expire -r production
Your Ruby version is 1.9.3, but your G
当我运行命令heroku run rake db:migrate将我的应用部署到Heroku时,我得到了这个错误:
PG::Error: ERROR: relation "roles" does not exist
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.
我使用的是Heroku,通常我会执行如下命令:
heroku run rake db:reset --app myapp
这会重置我的数据库。我在网上读到,Heroku并不支持所有的rake命令(包括db:reset,但这篇文章可能已经过时了?因为它对我来说很好)
然而,我有一个生产应用程序和一个临时应用程序,并担心我的深夜编程,关于我的生产应用程序上的db:reset意外命中。
有没有一种方法可以用下面这样的命令实现预防确认:
heroku run rake db:reset --app myapp or heroku run rake db:migrate --app myapp
或
gi