gpt4 book ai didi

sqlite - Bundle Exec Rake DB 迁移错误

转载 作者:行者123 更新时间:2023-12-01 16:23:14 24 4
gpt4 key购买 nike

当我为基本 RoR 网站运行 bundle exec rake db:migrate 时,出现此错误。我是一个初学者,在这个网站和 Treehouse 上发现了类似的错误,但与该错误的后半部分没有任何关系(从 NOT NULLC 开始)。我仍然不确定如何解决这个问题 - 有人可以建议吗?我正在 Windows 上运行这个。

SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "em
ail" varchar(255) DEFAULT '' NOT NULLC:/Sites/code/omrails-master/db/migrate/201
30804201341_add_devise_to_users.rb:5:in `block in up'

最佳答案

SQlite 错误显示您已经为用户表创建了电子邮件字段。

添加“电子邮件”varchar(255) DEFAULT '' NOT NULL。所以尝试使用“不同的列名称”

或删除旧的迁移。

def change 
remove_column :users, :email, <type>
end

之后使用此迁移

def up
add_column :users, :email, :string
end


def down
remove_column :users, :email, :string
end

关于sqlite - Bundle Exec Rake DB 迁移错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18049908/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com