我继续安装红宝石创业板Attachinary
并试图运行db:migrate
后收到此错误:指标名称太长attachinary/PostgreSQL的
Index name 'index_attachinary_files_on_attachinariable_type_and_attachinariable_id' on table 'attachinary_files' is too long; the limit is 63 characters
我一直在寻找,寻找一个解决方案,当然听说过给索引命名以避免生成的索引,但它似乎不起作用。其实有一个名称字段已经写着:
'name: by_scoped_parent'
这里是我的迁移文件的完整行:
add_index :attachinary_files, [:attachinariable_type, :attachinariable_id, :scope], name: 'by_scoped_parent'
下面是迁移文件的内容:
class CreateAttachinaryTables < ActiveRecord::Migration[5.1]
def change
create_table :attachinary_files do |t|
t.references :attachinariable, polymorphic: true
t.string :scope
t.string :public_id
t.string :version
t.integer :width
t.integer :height
t.string :format
t.string :resource_type
t.timestamps
end
add_index :attachinary_files, [:attachinariable_type, :attachinariable_id, :scope], name: 'by_scoped_parent'
end
end
注意:在我的db/migrate文件夹中没有任何双倍数据。最后的迁移文件非常好。
我目前正在学习Rails,所以我希望有人能帮助并原谅我,如果这是一个愚蠢的问题。
在此先感谢!
您是否生成过两次迁移? –
嘿@AlejandroMontilla!它实际上这里迁移 –
是我所得到的终端后,轨道DB之前停止:迁移--trace: “**调用分贝:迁移(FIRST_TIME) **调用环境(FIRST_TIME) **执行环境 * *调用数据库:load_config(first_time) **执行数据库:load_config **执行数据库:迁移 == 20170614155451 CreateAttachinaryTables:迁移===================== ===== - create_table(:attachinary_files) rails中止! StandardError:发生错误,此次及以后所有迁移取消: 表'attachinary_files'上的索引名称'index_attachinary_files_on_attachinariable_type_and_attachinariable_id'太长..' –