Avoid duplicate column Error in Migration

/ Published in: Rails
Save to your folder(s)

Add "rescue nil" to migration commands that you want the migration to try but don't care if it fails. Helpful for debugging migrations and helpful when you want to modify a previous migration, let's say add a column, and you don't want the remove column in the drop block to choke your reverse migration.

Copy this code and paste it in your HTML
  1. add_column :users, :ssn_part, :string rescue nil

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.