【发布时间】:2012-10-31 06:41:06
【问题描述】:
每当我在 Rails 应用程序中运行迁移时,都会收到来自 SQLite3 的错误:
SQLite3::SQLException: duplicate column name: photo_file_name: ALTER TABLE "users" ADD "photo_file_name" varchar(255)
我已经进行了“向用户添加照片”迁移。这里是:
class AddAttachmentPhotoToUsers < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.has_attached_file :photo
end
end
def self.down
drop_attached_file :users, :photo
end
end
这是用户迁移:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :title
t.string :department
t.text :skills
t.boolean :available
t.timestamps
end
end
end
我对此有点困惑,因为它告诉我有一个重复的列名“photo_file_name”,但我需要将它添加到用户表中?那没有意义。我不需要删除它吗?
如果您需要有关我的应用的任何其他详细信息,请告诉我。
【问题讨论】:
标签: ruby-on-rails sqlite migration paperclip