Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 :before?

like image 206
Gregg Horton Avatar asked Oct 26 '16 21:10

Gregg Horton


1 Answers

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.

like image 176
Zoran Avatar answered Sep 22 '22 18:09

Zoran