我有一個非常簡單的遷移不工作:運行remove_column在軌遷移
class RemoveAuthorIdFromBooks < ActiveRecord::Migration
def change
remove_column :books, :author_id
end
end
,但我得到了以下錯誤:
Mysql2::Error: Error on rename of './mysite_staging/#sql-3b1_3c78' to './mysite_staging/books' (errno: 150): ALTER TABLE `books` DROP `author_id`
這是表的說明:
+------------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+---------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| author_id | int(11) | NO | MUL | NULL | |
| title | varchar(255) | NO | | NULL | |
| teaser | varchar(500) | NO | | NULL | |
| description | varchar(2000) | YES | | NULL | |
| cover_image | varchar(255) | NO | | NULL | |
| publication_date | date | NO | | NULL | |
| enabled | tinyint(1) | NO | | 1 | |
| created_at | datetime | NO | | NULL | |
| updated_at | datetime | NO | | NULL | |
| excerpt | text | YES | | NULL | |
| featured | tinyint(1) | YES | | NULL | |
| site_id | int(11) | YES | | NULL | |
+------------------+---------------+------+-----+---------+----------------+
任何線索?
什麼是當前表的樣子? ('rails db'然後描述書籍)。另外,你使用的是什麼版本(Rails,Mysql2。OS?) – Novae 2013-02-14 20:02:45
Rails 3,mysql2,Ubuntu on Amazon ec2。 – Tony 2013-02-14 20:06:45
可能與http://stackoverflow.com/q/1451042/684934 – bdares 2013-02-14 20:13:06