I am trying to remove a reference column from my database, locally using sqlite3.
Was getting the SQLite3::ConstraintException: FOREIGN KEY constraint failed: DROP TABLE "features"
so I tried removing the foreign key first. That did not change anything in my schema file, other than the version because a migration was successfully run.
Now trying
def up
remove_index :features, column: [:user_id]
end
def down
add_index :features, column: [:user_id]
end
And this replaces
t.index ["user_id"], name: "index_features_on_user_id"
with t.index [nil], name: "index_features_on_user"
I tried playing with the remove_index to be just :user
or :user_id
as the second parameter, but no luck.
I even tried to add a name and the same nil remove_index :features, :user_id, name: :index_features_on_user
Ultimately I want to remove the entire reference to user, the t.index
and the t.integer "user_id"
, but have not been successful and thought it was because there was that index sitting there refusing to be deleted, but I could be wrong.
UPDATE
Here is the features table
create_table "features", force: :cascade do |t|
t.integer "instance_id"
t.integer "user_id"
t.integer "experiment_id"
t.string "name"
t.text "values"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "is_allow_na", default: false, null: false
t.index ["experiment_id"], name: "index_features_on_experiment_id"
t.index ["instance_id"], name: "index_features_on_instance_id"
t.index ["user_id"], name: "index_features_on_user_id"
end