我已经从用户表开始我的项目,并且已经迁移到使用帐户表。在此过程中,我的 schema.rb 文件中仍有对 Users 表的旧引用,我需要将其删除并创建新引用或更新引用。
我正在尝试制定一个允许我执行此操作的迁移,但是由于没有 Users 表并且当它确实存在时,它一直抛出错误,它从来没有 account_id ,您可以在我的 schema.rb 文件中看到它的引用.
我真的只需要我的 schema.rb 文件来更新 "add_foreign_key "likes", "users", column: "account_id"
至
add_foreign_key "likes", "accounts", column: "account_id"
但是我发现这不可能在不产生错误的情况下进行迁移。
有什么建议么?
ActiveRecord::Schema.define(version: 2022_01_18_013836) do
create_table "accounts", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at", precision: 6
t.datetime "remember_created_at", precision: 6
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "username"
t.string "first_name"
t.string "last_name"
t.index ["email"], name: "index_accounts_on_email", unique: true
t.index ["reset_password_token"], name: "index_accounts_on_reset_password_token", unique: true
end
create_table "likes", force: :cascade do |t|
t.integer "account_id", null: false
t.integer "product_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["account_id"], name: "index_likes_on_account_id"
t.index ["product_id"], name: "index_likes_on_product_id"
end
create_table "products", force: :cascade do |t|
t.string "product_name"
t.string "product_category"
t.string "product_type"
t.string "product_image"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.text "product_description"
t.string "product_country"
end
add_foreign_key "likes", "products"
add_foreign_key "likes", "users", column: "account_id"
end