我是一个新手,试图通过使用ROR版本5.0和mysql 8.02跟随Lynda视频系列学习ruby on rails。在DB> migrate> model. rb文件中创建表条目并运行"rails db:migrate"后,我在终端中得到一个错误,这没有太大意义。iv使用不同的用户和光栅它mysql特权和搜索在网上,但没有运气。
class Username <ActiveRecord::Migration [5.0]
def up create_table:用户做|不|
t.column "first_name", :string, :limit => 25
t.string "last_name", :limit => 50
t.string "email", :default => '', :null => false
t.string "password", :limit => 40
t.timestamps
end
端
def down
drop_table :users
端
结束
MBP:simple_cms $rails db:migrate rails aborted! ActiveRecord::StatementInvalid:错误提示:未知排序规则:'utf8_0900_ai_ci':CREATE TABLE schema_migrations
(version
varchar(255)COLLATE utf8_0900_ai_ci PRIMARY KEY)ENGINE = InnoDB/Users/. rvm/gems/ruby-2.3.0/gems/mysql2 - 0.4.9/lib/mysql2/client. rb:一百二十:在查询"/Users/"中的_query' /Users/.rvm/gems/ruby-2.3.0/gems/mysql2-0.4.9/lib/mysql2/client.rb:120:in
块中。rvm/gems/ruby-2.3.0/gems/mysql2 - 0.4.9/lib/mysql2/client. rb:一百一十九:在handle_interrupt' /Users/.rvm/gems/ruby-2.3.0/gems/mysql2-0.4.9/lib/mysql2/client.rb:119:in
query '/Users/中。rvm/gems/ruby-2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/abstract_mysql_adapter。rb:二百一十八:在log '/Users/中block in execute' /Users/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/abstract_adapter.rb:590:in
块中。rvm/gems/ruby-2.3.0/gems/activesupport-5.0.6/lib/active_support/notifications/instrumenter。rb:二十一:在instrument' /Users/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/abstract_adapter.rb:583:in
log '/Users/中。rvm/gems/ruby-2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/abstract_mysql_adapter。rb:二百一十八:在execute' /Users/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/mysql/database_statements.rb:31:in
中执行"/Users/。rvm/gems/ruby-2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/abstract/schema_statements。rb:二百七十八:在create_table' /Users/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:423:in
create_table '/Users/中。rvm/gems/ruby-2.3.0/gems/activerecord-5.0.6/lib/active_record/schema_migration. rb:二十七:在create_table' /Users/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:1008:in
initialize_schema_migrations_table'中
3条答案
按热度按时间wswtfjt71#
有一个问题与您的问题有关:https://github.com/rails/rails/issues/28730
这个问题在
rails v5.1.0.rc2
中得到了解决。升级到最新版本并重新生成schema.rb
应该可以消除您的问题。eufgjt7s2#
如果
utf8_0900_ai_ci
不工作,也可以将通用collation
添加到database.yml
:r6hnlfcb3#
对于那些不能升级到rails
v5.1.0.rc2
,并且将collation
添加到database.yml
不起作用的人,应该在数据库级别修改排序规则。在mysql控制台中运行以下命令: