为什么我的迁移导致“NoMethodError:未定义的方法`jsonb'用于#<activerecord :: connectionadapters :: mysql :: tabledefinition”?

时间:2018-04-03 02:49:57

标签: ruby-on-rails rubygems repository

=“”

我遇到了很多问题,因为在安装过程中,迁移文件停止运行,剩下的2个不会迁移到期到jsonb问题。但是,如果我将它安装为gem,则此存储库可以正常工作。

存储库 - https://github.com/SpinaCMS/Spina

版本:

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin17]
Rails 5.1.6
rvm 1.29.3 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

在本地运行安装:

MacBook-Pro:tgs Work$ rails g spina:install
Running via Spring preloader in process 15218
      create  config/initializers/spina.rb
      create  config/initializers/carrierwave.rb
      create  config/initializers/mobility.rb
       route  mount Spina::Engine => '/'
        rake  spina:install:migrations
Copied migration 20180403040054_create_spina_tables.spina.rb from spina
Copied migration 20180403040055_create_spina_translation_tables.spina.rb from spina
Copied migration 20180403040056_create_spina_navigations.spina.rb from spina
Copied migration 20180403040057_add_password_reset_token_to_spina_users.spina.rb from spina
Copied migration 20180403040058_remove_translated_columns.spina.rb from spina
Copied migration 20180403040059_create_spina_options.spina.rb from spina
Copied migration 20180403040060_create_spina_settings.spina.rb from spina
Copied migration 20180403040061_create_spina_media_folders.spina.rb from spina
        rake  db:migrate
== 20180403040054 CreateSpinaTables: migrating ================================
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_accounts", {:force=>:cascade, :id=>:integer})
   -> 0.0265s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_attachment_collections", {:force=>:cascade, :id=>:integer})
   -> 0.0182s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_attachment_collections_attachments", {:force=>:cascade, :id=>:integer})
   -> 0.0117s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_attachments", {:force=>:cascade, :id=>:integer})
   -> 0.0142s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_layout_parts", {:force=>:cascade, :id=>:integer})
   -> 0.0132s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_lines", {:force=>:cascade, :id=>:integer})
   -> 0.0147s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_page_parts", {:force=>:cascade, :id=>:integer})
   -> 0.0148s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_pages", {:force=>:cascade, :id=>:integer})
   -> 0.0158s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_photo_collections", {:force=>:cascade, :id=>:integer})
   -> 0.0110s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_photo_collections_photos", {:force=>:cascade, :id=>:integer})
   -> 0.0130s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_photos", {:force=>:cascade, :id=>:integer})
   -> 0.0120s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_structure_items", {:force=>:cascade, :id=>:integer})
   -> 0.0142s
-- add_index("spina_structure_items", ["structure_id"], {:name=>"index_spina_structure_items_on_structure_id", :using=>:btree})
   -> 0.0117s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_structure_parts", {:force=>:cascade, :id=>:integer})
   -> 0.0144s
-- add_index("spina_structure_parts", ["structure_item_id"], {:name=>"index_spina_structure_parts_on_structure_item_id", :using=>:btree})
   -> 0.0129s
-- add_index("spina_structure_parts", ["structure_partable_id"], {:name=>"index_spina_structure_parts_on_structure_partable_id", :using=>:btree})
   -> 0.0149s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_structures", {:force=>:cascade, :id=>:integer})
   -> 0.0142s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_texts", {:force=>:cascade, :id=>:integer})
   -> 0.0148s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_users", {:force=>:cascade, :id=>:integer})
   -> 0.0118s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_rewrite_rules", {:force=>:cascade, :id=>:integer})
   -> 0.0143s
== 20180403040054 CreateSpinaTables: migrated (0.2917s) =======================

== 20180403040055 CreateSpinaTranslationTables: migrating =====================
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_page_translations", {:force=>:cascade, :id=>:integer})
   -> 0.0138s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_line_translations", {:force=>:cascade, :id=>:integer})
   -> 0.0168s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_text_translations", {:force=>:cascade, :id=>:integer})
   -> 0.0160s
== 20180403040055 CreateSpinaTranslationTables: migrated (0.0474s) ============

== 20180403040056 CreateSpinaNavigations: migrating ===========================
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_navigations", {:force=>:cascade, :id=>:integer})
   -> 0.0148s
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table("spina_navigation_items", {:force=>:cascade, :id=>:integer})
   -> 0.0120s
== 20180403040056 CreateSpinaNavigations: migrated (0.0271s) ==================

== 20180403040057 AddPasswordResetTokenToSpinaUsers: migrating ================
-- add_column(:spina_users, :password_reset_token, :string)
   -> 0.0162s
-- add_column(:spina_users, :password_reset_sent_at, :datetime)
   -> 0.0137s
== 20180403040057 AddPasswordResetTokenToSpinaUsers: migrated (0.0301s) =======

== 20180403040058 RemoveTranslatedColumns: migrating ==========================
-- remove_column(:spina_lines, :content)
   -> 0.0153s
-- remove_column(:spina_texts, :content)
   -> 0.0143s
-- remove_column(:spina_pages, :title)
   -> 0.0161s
-- remove_column(:spina_pages, :menu_title)
   -> 0.0125s
-- remove_column(:spina_pages, :description)
   -> 0.0179s
-- remove_column(:spina_pages, :seo_title)
   -> 0.0140s
-- remove_column(:spina_pages, :materialized_path)
   -> 0.0182s
== 20180403040058 RemoveTranslatedColumns: migrated (0.1087s) =================

== 20180403040059 CreateSpinaOptions: migrating ===============================
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table(:spina_options, {:id=>:integer})
   -> 0.0130s
== 20180403040059 CreateSpinaOptions: migrated (0.0134s) ======================

== 20180403040060 CreateSpinaSettings: migrating ==============================
-- adapter_name()
   -> 0.0000s
-- adapter_name()
   -> 0.0000s
-- create_table(:spina_settings, {:id=>:integer})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

undefined method `jsonb' for #<ActiveRecord::ConnectionAdapters::MySQL::TableDefinition:0x007fb0f1c4a2d0>
Did you mean?  json
/Users/work/Documents/Working/tgs/db/migrate/20180403040060_create_spina_settings.spina.rb:6:in `block in change'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration/compatibility.rb:46:in `block in create_table'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:282:in `create_table'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:363:in `create_table'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:849:in `block in method_missing'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:818:in `block in say_with_time'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:818:in `say_with_time'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:838:in `method_missing'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration/compatibility.rb:45:in `create_table'
/Users/work/Documents/Working/tgs/db/migrate/20180403040060_create_spina_settings.spina.rb:4:in `change'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:792:in `exec_migration'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:776:in `block (2 levels) in migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:775:in `block in migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:408:in `with_connection'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:774:in `migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:953:in `migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1230:in `block in execute_migration_in_transaction'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1300:in `ddl_transaction'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1229:in `execute_migration_in_transaction'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1201:in `block in migrate_without_lock'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1200:in `each'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1200:in `migrate_without_lock'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1148:in `block in migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1317:in `with_advisory_lock'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1148:in `migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1007:in `up'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:985:in `migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/Users/work/.rvm/gems/ruby-2.4.1/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
/Users/work/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
/Users/work/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'

Caused by:
NoMethodError: undefined method `jsonb' for #<ActiveRecord::ConnectionAdapters::MySQL::TableDefinition:0x007fb0f1c4a2d0>
Did you mean?  json
/Users/work/Documents/Working/tgs/db/migrate/20180403040060_create_spina_settings.spina.rb:6:in `block in change'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration/compatibility.rb:46:in `block in create_table'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:282:in `create_table'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:363:in `create_table'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:849:in `block in method_missing'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:818:in `block in say_with_time'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:818:in `say_with_time'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:838:in `method_missing'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration/compatibility.rb:45:in `create_table'
/Users/work/Documents/Working/tgs/db/migrate/20180403040060_create_spina_settings.spina.rb:4:in `change'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:792:in `exec_migration'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:776:in `block (2 levels) in migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:775:in `block in migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:408:in `with_connection'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:774:in `migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:953:in `migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1230:in `block in execute_migration_in_transaction'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1300:in `ddl_transaction'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1229:in `execute_migration_in_transaction'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1201:in `block in migrate_without_lock'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1200:in `each'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1200:in `migrate_without_lock'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1148:in `block in migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1317:in `with_advisory_lock'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1148:in `migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:1007:in `up'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/migration.rb:985:in `migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/Users/work/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/Users/work/.rvm/gems/ruby-2.4.1/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
/Users/work/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
/Users/work/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:migrate

1 个答案:

答案 0 :(得分:1)

看起来您正尝试在本地系统中使用sqlite数据库执行此操作,sqlite没有json支持,请尝试将数据库更改为{{1} },mysql或具有json支持的数据库系统。