Make sure you don't conflate your table schema (which columns your data has) with the actual data (the rows with those columns).
Does it make sense now why removing the last_name column will not delete any rows. It will keep all rows, but delete that column from all rows.
So, as @xxx said, add the columns (migrate the schema), and then populate them (migrate the data).
If you want to clean up all those extra records created from your botched migration, well shame on you, always back up your database before running a migration. ;)
But maybe a more helpful answer: You could use the created_at
date to find all the records created as part of your first migration, then delete them. Something like
# e.g. if you want to delete all records created since
# your migration which you ran 2 days ago
People.where("created_at > ?", 2.days.ago).destroy_all
Make sure to back up your db before you try that one...
And then, back to your original question, how to migrate the data from a single name field to first/last names. Once you've added the new columns, try iterating over each person like this:
People.each do |person|
new_first_name, new_last_name = person.name.split
person.update_attributes(
first_name: new_first_name,
last_name: new_last_name
)
end