Ric*_*ton 9 ruby postgresql ruby-on-rails heroku ruby-on-rails-3
我正在尝试将一个简单的应用程序推送到heroku并运行:
heroku rake db:migrate
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
rake aborted!
PGError: ERROR: relation "posts" 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.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"posts"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
Run Code Online (Sandbox Code Playgroud)
我的迁移看起来像这样:
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.string :source
t.string :tweetid
t.string :pure
t.string :media
t.string :destination
t.datetime :time
t.timestamps
end
end
end
Run Code Online (Sandbox Code Playgroud)
并且,在提到另一个SO答案后,我在我的Gemfile中包含以下内容:
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
gem 'pg'
end
Run Code Online (Sandbox Code Playgroud)
预先感谢您的任何帮助!
---更新---
我感到困惑的主要原因是这一切都在本地工作,而不是在我在heroku上运行迁移时.
这是我现在得到的错误:
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)
Run Code Online (Sandbox Code Playgroud)
我一直在看这个问题:
启动rails3.1应用程序缺少postgres gem时Heroku错误
我几乎可以肯定我的database.yml应该看起来不像这样(因为我需要运行postgresql !!!):
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
Run Code Online (Sandbox Code Playgroud)
对于这里的忠诚表示严肃的道歉.提前谢谢你的帮助!
也试过这个链接:上传到Heroku DB rake:迁移问题
| 归档时间: |
|
| 查看次数: |
20681 次 |
| 最近记录: |