Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rake attachinary:install:migrations -> Index table names are too long #154

Open
mklb opened this issue Nov 27, 2017 · 2 comments
Open

rake attachinary:install:migrations -> Index table names are too long #154

mklb opened this issue Nov 27, 2017 · 2 comments

Comments

@mklb
Copy link

mklb commented Nov 27, 2017

After running rake attachinary:install:migrations I get the following output

WARNING: Use strings for Figaro configuration. 587 was converted to "587".
== 20171127085142 CreateAttachinaryTables: migrating ==========================
-- create_table(:attachinary_files)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Index name 'index_attachinary_files_on_attachinariable_type_and_attachinariable_id' on table 'attachinary_files' is too long; the limit is 63 characters
@mklb
Copy link
Author

mklb commented Nov 27, 2017

The fix is to add an own index name to the attachinariable reference. t.references :attachinariable, polymorphic: true, index: {name: "index_attachinary_files_attachinariable"}. Also note that I added [5.1] to the ActiveRecord::Migration Class because it was missing. (I am running Rails 5.1 so add your version)

class CreateAttachinaryTables < ActiveRecord::Migration[5.1]
  def change
    create_table :attachinary_files do |t|
      t.references :attachinariable, polymorphic: true, index: {name: "index_attachinary_files_attachinariable"}
      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

@lopezjurip
Copy link

Thanks @mklb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants