2011-02-01 218 views
0

我剛剛通過應用程序和db使用rake db:migrate進行了更新。但是,我遇到了一個錯誤:數據庫遷移問題

Migrating to CreateSavedBoards (20110111184104) 
== CreateSavedBoards: migrating ============================================== 
-- drop_table(:boards) 
    SQL (0.0ms) Mysql::Error: Unknown table 'boards': DROP TABLE `boards` 
rake aborted! 
An error has occurred, all later migrations canceled: 

Mysql::Error: Unknown table 'boards': DROP TABLE `boards` 

(See full trace by running task with --trace) 

遷移文件導致錯誤?

class CreateBoardCategoriesSavedboards < ActiveRecord::Migration 
    def self.up 
    create_table :board_categories_boards, :id => false do |t| 
     t.integer :board_category_id 
     t.integer :board_id 
    end 

    add_index :board_categories_boards, [:board_category_id, :board_id], :name => "bcb_board_category_id_board_id" 
    end 

    def self.down 
    drop_table :board_categories_boards 
    end 
end 

這是委員會的模型。

class Board < ActiveRecord::Base 
    belongs_to :image, :foreign_key => 'image' 
    belongs_to :clip, :foreign_key => 'clip' 
    has_and_belongs_to_many :categories, :class_name => 'BoardCategory', :foreign_key => 'board_id' 
    has_many :comments, :as => :commentable 
    set_table_name "savedboards" 
end 

我想到的是,錯誤來自Rails的思維,有一個boards表,因爲在上面的遷移文件的board_id

我是否認爲這可能會導致遷移失敗,我該怎麼辦?

回答

1

該遷移的輸出顯示drop_table :boards正在發生,但它未顯示在您的遷移中。也許這是一個早期的遷移,試圖刪除boards表?

+0

完全和它似乎是舊的遷移ID CreateSavedBoards – Mike 2011-02-01 12:08:09