ruby 无法使用rails migration创建数据库

ivqmmu1c  于 12个月前  发布在  Ruby
关注(0)|答案(1)|浏览(82)

我刚刚遇到了使用rails db:migrate的问题。下面的图片显示了我遇到的问题。[ This is the error when I run command rails db:migrate ](https://i.stack.imgur.com/Q696O.png
这是我的代码:

class CreateAdmins < ActiveRecord::Migration[7.0]
  def change
    create_table :admins do |t|

      t.string :email, limit: 50
      t.string :encrypted_password, limit: 100
      t.integer :sign_in_count, default: 0
      t.string :hashid1, limit: 100
      t.string :hashid2, limit: 100
      t.string :encrypted_fullname_vi, limit: 100
      t.string :encrypted_fullname_en, limit: 100
      t.string :encrypted_birthday, limit: 100
      t.string :encrypted_address, limit: 100
      t.string :nickname
      t.json :image_json
      t.integer :show_avatar, limit: 1, default: 0

      t.timestamps
    end
  end
end

我在这个论坛上尝试了很多方法,但仍然无效。我该怎么办?
以下是关于我的环境的详细信息:Ruby:3.1.4 Rails 7.0.8迁移:7.0

7tofc5zh

7tofc5zh1#

我认为你已经用Postgres标志创建了你的Rails项目,但是你正在使用MySQL 2 gem和/或连接到MySQL数据库。
如果你想解决这个问题,你可以切换到Postgres数据库,或者使用MySQL 2 gem重新运行你的模型脚手架。
您可以运行bin/rails db:drop db:create重新启动。

相关问题