Can you really change a area this is a string for an integer without clearing the information already joined?

The present db structure for that table under consideration is:

create_table :people do |t|
t.string :company_id

Is possible using migrations?

I am thinking maybe within the migration drop that old area, create a replacement that's an integer - but I am worried this can obvious all the data already joined.

Thanks,

Danny

Don't drop the column, it'll obvious the information.

You are able to however try

change_column :people, :company_id, :integer

and when all values in company_id could be transformed into integer, it ought to be fine.

If that's not the situation (ie not every string could be converted automatically), then it can be done in 2 steps: 1) produce a new column, then load the company_id inside after a little conversion. 2) drop company_id then relabel the brand new column.

You ought to be careful with both techniques (much more for that second one) and you ought to most likely get it done first on the copy from the database, if you're able to.