I have generated the migration file and added t.string :address. before ''' rails db:migrate''' I added the line-
add_column :users, :address, :string, limit: 10, after: :email
but it was added last on the table
t.datetime "updated_at", null: false
t.string "address", limit: 10
Expected as
t.string "email"
t.string "address", limit: 10
Is there any way to cop with this problem
The
after
option foradd_column
is not supported by SQLite, it's specific to MySQL. As SQLite does not support reordering of columns natively, if the column order is crucial, you would need to recreate the table with the desired column order.As others have mentioned in the comments, column order in a table is not significant in terms of functionality. So if this is just for aesthetic reasons, it's usually not worth the effort to make the change.