Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RubyonRails迁移错误_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails RubyonRails迁移错误

Ruby on rails RubyonRails迁移错误,ruby-on-rails,ruby,Ruby On Rails,Ruby,每当我尝试运行rails db:migrate时,我安装了一个gem作为标记,它将输出以下内容: C:\Sites\novosti>rails db:migrate rails aborted! StandardError: An error has occurred, this and all later migrations canceled: Directly inheriting from ActiveRecord::Migration is not supported. Ple

每当我尝试运行rails db:migrate时,我安装了一个gem作为标记,它将输出以下内容:

C:\Sites\novosti>rails db:migrate
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2]
C:/Sites/novosti/db/migrate/20170708123900_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb:2:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2]
C:/Sites/novosti/db/migrate/20170708123900_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb:2:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

表上的索引名称应该是唯一的。这是db的一个错误,因为索引已经存在。请在迁移之前删除数据库表中的索引,或者如果表中的索引已经正常,则可以删除迁移中的添加索引

似乎已经创建了索引“index\u taggings\u on\u tag\u id”,可能是由于以前失败的迁移,尝试将其从数据库中删除,然后再次运行迁移。我尝试删除add_索引,但这导致我添加了更多[5.0],当我这样做时,另一个错误弹出,在标记上没有找到带有所提供选项的索引。C:/Sites/novosti/db/migrate/201707090702添加缺少唯一索引。在引擎上充当标记。rb:7:in up“bin/rails:4:in require”bin/rails:4:in“argument错误:在提供选项的标记上找不到索引。C:/Sites/novosti/db/migrate/201707090702\u添加\u缺少\u唯一\u索引。充当\u引擎上的\u标记\u。rb:7:in up'bin/rails:4:in require'bin/rails:4:in'您能解释一下您是如何使用它的吗?我希望您在操作之前尝试检查索引是否存在,您可以共享/检查该行吗?我希望我可以使用它,但它没有帮助我根本无法使用它我需要运行db:migrate,但我不能,因为它会导致错误我在安装时丢弃了整个数据库。它说索引已经存在
C:\Sites\novosti>rails db:migrate
== 20170708123900 ActsAsTaggableOnMigration: migrating ========================
-- create_table(:tags)
   -> 0.0028s
-- create_table(:taggings)
   -> 0.0033s
-- add_index(:taggings, :tag_id)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Index name 'index_taggings_on_tag_id' on table 'taggings' already exists
C:/Sites/novosti/db/migrate/20170708123900_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb:23:in `up'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
ArgumentError: Index name 'index_taggings_on_tag_id' on table 'taggings' already exists
C:/Sites/novosti/db/migrate/20170708123900_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb:23:in `up'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)