0

For some reason I have a Rails app that's running perfectly fine on one system at the moment, but I cannot seem to migrate the database migration files on another system that's trying to replicate the same thing.

Here's an example of the error that I'm getting:

== 20181024060925 CreateNetworkStalkerSubDomains: migrating ====================
-- create_table(:network_stalker_sub_domains) rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
Index name 'index_network_stalker_sub_domains_on_network_stalker_ip_address_id' on table 'network_stalker_sub_domains' is too long; the limit is 62 characters

And then here's the migration file

class CreateNetworkStalkerSubDomains < ActiveRecord::Migration[5.1]
  def change
    create_table :network_stalker_sub_domains do |t|
      t.belongs_to :network_stalker_ip_address, foreign_key: true
      t.string :name

      t.timestamps
    end
  end
end

I have some joins tables that I fixed this issue by adding a name: and unique: parameter and it worked successfully, but I'm not quite sure how to fix this one.

halfer
  • 19,824
  • 17
  • 99
  • 186
LewlSauce
  • 5,326
  • 8
  • 44
  • 91
  • Check here: https://stackoverflow.com/questions/5443740/how-do-i-handle-too-long-index-names-in-a-ruby-on-rails-activerecord-migration – iGian May 25 '19 at 02:29
  • @iGian so this is the solution I had applied when using `references`, but what about `belongs_to`? I guess I'm wondering if I would be taking this `belongs_to` line and converting it to `add_index :network_stalke_ip_address, :unique => true, :name => "randomname"`? – LewlSauce May 25 '19 at 02:30
  • 1
    @LewlSauce `belongs_to` is simply an alias for `references`, so @iGian's link will apply the same – Mark Merritt May 25 '19 at 02:46
  • @MarkMerritt gotcha. Thanks so much! – LewlSauce May 25 '19 at 02:48

0 Answers0