I'm on a git branch and trying to rollback two migrations, before destroying the branch. The most recent migration adds a column to a table that I want to keep (and which is part of master, not the branch to be dropped), so dropping the whole table is not a solution (unless I have to recreate it again). Anyways, I must have done something wrong, because when I tried to remove the apple_id column from the scores table, I got this abort error.
This is the migration that I'm trying to rollback
add_column :scores, :apple_id, :integer
However, the error message (see below) is referring to the indexes that I created with the original migration (part of master branch) that created the table
add_index :scores, [:user_id, :created_at, :funded, :started]
Can you suggest what I might do?
== AddAppleidColumnToScores: reverting =======================================
-- remove_column("scores", :apple_id)
rake aborted!
An error has occurred, this and all later migrations canceled:
Index name 'temp_index_altered_scores_on_user_id_and_created_at_and_funded_and_started' on table 'altered_scores' is too long; the limit is 64 characters
Update: reading this SO question How do I handle too long index names in a Ruby on Rails migration with MySQL?, I got some more information about the source of the problem but don't know how to solve it. Both sql and postgres have 64 character limits
Index name 'index_studies_on_user_id_and_university_id_and_subject_\
name_id_and_subject_type_id' on table 'studies' is too long; \
the limit is 64 characters
The accepted answer for the question I refer to says to give the index a name, although I'm not sure how I could do this now that I'm trying to rollback.
add_index :studies, ["user_id", "university_id", \
"subject_name_id", "subject_type_id"],
:unique => true, :name => 'my_index'
Update: in response to the comments, I'm using Rails 3.2.12. This is the migration that adds the column
class AddAppleidColumnToScores < ActiveRecord::Migration
def change
add_column :scores, :apple_id, :integer
end
end
Furthermore, the reason why I didn't want to drop the table was that I was unsure about what problems it might cause in recreating it since a) the main part was created on branch master, while a column added on a branch and b) I was unsure about what to do with the migration file for the dropped table? since it was the fourth (of about 10) tables I created, I don't know how to run it and only it again.