私は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フォルダーにはdoublonがありません。最後の移行ファイルは完全にうまくいった。
私は現在Railsを学んでいますので、もし愚かな質問であれば誰かが助けてくれたらと願っています。
ありがとうございます!あなたは、移行に伴う、この行にエラーを取得している
2つの移行を生成しましたか? –
ちょっと@AlejandroMontilla! *(FIRST_TIME) を移行**起動環境(FIRST_TIME) **環境 を実行します。それは実際にここに –
を移行する前に停止し、私はレールデシベル後にターミナルで得るものです:--traceを移行: 「** DBを起動します* DBを起動します。load_config(FIRST_TIME) は**デシベルを実行します。load_config **はデシベルを実行します。 == 20170614155451 CreateAttachinaryTables移行:移行を===================== ===== - create_table(:attachinary_files) レールが中止されました! StandardError:エラーが発生しました。これ以降の移行はキャンセルされました: 'attach__files'テーブルのインデックス名 'index_attachinary_files_on_attachinariable_type_and_attachinariable_id'が長すぎます.. ' –