t
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了t相关的知识,希望对你有一定的参考价值。
class CreateUsers < ActiveRecord::Migration[6.0]
def change
create_table :users do |t|
t.string :user
t.timestamps
end
end
end
class CreateArticles < ActiveRecord::Migration[6.0]
def change
create_table :articles do |t|
t.string :content
t.timestamps
end
end
end
我在一个新项目中创建了这两个实体,当我运行迁移时,我得到了这个错误。
rails db:setup
Created database 'rails_api_development'
Created database 'rails_api_test'
C:/Users/admin/Desktop/projects/rails-api/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter C:/Users/admin/Desktop/projects/rails-api/config/application.rb to limit the frameworks that will be loaded.
admin@Desktop MINGW32 ~/Desktop/projects/rails-api (master)
$ rails db:migrate
rails aborted!
ActiveRecord::StatementInvalid: mysql2::Error: Specified key was too long; max key length is 1000 bytes
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Caused by:
Mysql2::Error: Specified key was too long; max key length is 1000 bytes
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
另外,为什么它说mysql2 即使我输入mysql作为数据库?rails到底出了什么问题?是ORM的问题还是其他配置问题?
以上是关于t的主要内容,如果未能解决你的问题,请参考以下文章
CentOS yum 命令出现 [Errno 14] curl#6 - "Couldn't resolve host ..." 的解决方法(代码片段
java.util.MissingResourceException: Can't find bundle for base name init, locale zh_CN问题的处理(代码片段
[react] Module not found: Can't resolve 'schedule' in 'C:Usersadcaldvmtn7myapp (代码片段