Gregg Horton Gregg Horton - 1 year ago 73
Ruby Question

Adding a column before another one in Rails

I'm looking to put a column at the front of my table I know you can do

add_column :customer, :first_name, after: :last_name

but is there a way to do

Answer Source

You're able to insert a column at the front of your table by using the :first option:

add_column :table_name, :column_name, :column_type, first: true

You can still use :after to handle all other positioning cases.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download