我有一个非常简单的迁移:
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 | |
+------------------+---------------+------+-----+---------+----------------+
有什么线索吗?