我試圖把一個簡單的應用程序最多的Heroku和運行:PGError:ERROR:關係 「表格名」 不存在
heroku rake db:migrate
,但我得到了以下錯誤:
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)
我遷移是這樣的:
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
而且,參照其他的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
預先感謝您的幫助!
--- UPDATE ---
主要的原因我感到困惑的是,當我運行在Heroku遷移這一切本地工作,只是沒有。
以下是錯誤我現在得到:
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)
我一直在尋找這樣一個問題:
Heroku error when launch rails3.1 app missing postgres gem
我幾乎確信我的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
S對這裏的庸俗性非常道歉。提前謝謝你的幫助!
也試過此鏈接:Uploading to Heroku DB rake:migrate problem
寶石'pg'應該在組之外:資產塊,它與我想的沒有任何關係。你嘗試過'heroku rake db:setup'嗎? – Robin
你不需要pg在你的gemfile文件中爲heroku – fivetwentysix
對不起,這是一個早期的實驗,看看複數是否影響它。 –