我繼續安裝紅寶石創業板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'太長..' –