acts-as-taggable-onサイトを参考に導入し、次の順番に実行しました。
gemfile
1gem 'acts-as-taggable-on', '~> 6.0'
bash
1$ bundle install 2$ rails acts_as_taggable_on_engine:install:migrations 3$ rails db:migrate
上記最後のコマンドを実行した際、下記のエラーが発生してしましたまし。
パッと見何のエラーなのかはわかりますが、なぜ「起きたのか」と「対策」がわからない状態です。
ネットでも検索してみましたが、解決に至らずの状態です。。。
どなたか原因と対策が分かる方、ご教授お願い致します????♀️
bash
1== 20191121134718 ActsAsTaggableOnMigration: migrating ======================== 2-- create_table(:tags, {:options=>"ENGINE=InnoDB", :id=>:integer}) 3 -> 0.0398s 4-- create_table(:taggings, {:options=>"ENGINE=InnoDB", :id=>:integer}) 5 -> 0.0564s 6-- add_index(:taggings, :tag_id) 7 -> 0.0630s 8-- add_index(:taggings, [:taggable_id, :taggable_type, :context], {:name=>"taggings_taggable_context_idx"}) 9 -> 0.0484s 10== 20191121134718 ActsAsTaggableOnMigration: migrated (0.2116s) =============== 11 12== 20191121134719 AddMissingUniqueIndices: migrating ========================== 13-- add_index(:tags, :name, {:unique=>true}) 14 -> 0.0736s 15-- index_exists?(:taggings, :tag_id, {:name=>"index_taggings_on_tag_id"}) 16 -> 0.0120s 17-- remove_index(:taggings, {:column=>:tag_id, :name=>"index_taggings_on_tag_id"}) 18rails aborted! 19StandardError: An error has occurred, all later migrations canceled: 20 21Mysql2::Error: Cannot drop index 'index_taggings_on_tag_id': needed in a foreign key constraint: DROP INDEX `index_taggings_on_tag_id` ON `taggings` 22/usr/local/bundle/gems/mysql2-0.5.2/lib/mysql2/client.rb:131:in `_query' 23/usr/local/bundle/gems/mysql2-0.5.2/lib/mysql2/client.rb:131:in `block in query' 24/usr/local/bundle/gems/mysql2-0.5.2/lib/mysql2/client.rb:130:in `handle_interrupt' 25/usr/local/bundle/gems/mysql2-0.5.2/lib/mysql2/client.rb:130:in `query' 26/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute' 27/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' 28/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares' 29/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads' 30/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute' 31/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log' 32/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log' 33/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument' 34/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log' 35/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:185:in `execute' 36/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/mysql/database_statements.rb:28:in `execute' 37/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:788:in `remove_index' 38/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:871:in `block in method_missing' 39/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:840:in `block in say_with_time' 40/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:840:in `say_with_time' 41/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:860:in `method_missing' 42/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration/compatibility.rb:184:in `remove_index' 43/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:604:in `method_missing' 44/idea-note/db/migrate/20191121134719_add_missing_unique_indices.acts_as_taggable_on_engine.rb:11:in `up' 45/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:777:in `up' 46/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:817:in `exec_migration' 47/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:798:in `block (2 levels) in migrate' 48/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:797:in `block in migrate' 49/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection' 50/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:796:in `migrate' 51/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:977:in `migrate' 52/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction' 53/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1345:in `ddl_transaction' 54/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction' 55/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1263:in `block in migrate_without_lock' 56/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1262:in `each' 57/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1262:in `migrate_without_lock' 58/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1210:in `block in migrate' 59/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1363:in `with_advisory_lock' 60/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1210:in `migrate' 61/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1036:in `up' 62/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:1011:in `migrate' 63/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/tasks/database_tasks.rb:172:in `migrate' 64/usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <main>' 65/usr/local/bundle/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform' 66/usr/local/bundle/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:20:in `perform' 67/usr/local/bundle/gems/railties-5.2.3/lib/rails/command.rb:48:in `invoke' 68/usr/local/bundle/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<main>' 69/usr/local/bundle/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require' 70/usr/local/bundle/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi' 71/usr/local/bundle/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' 72/usr/local/bundle/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi' 73/usr/local/bundle/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' 74/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require' 75/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency' 76/usr/local/bundle/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require' 77bin/rails:4:in `<main>'
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/12/01 12:31