I have some major structure change issues with an ruby on rails
application, and I’d like to ask you about how i can handle that. I
make some dummy problems for you to show what i want to reach:
- Having a Client model with first_name and last_name should now come
together as name:
For the model it would be easy to have just
first_name + ’ ’ + last_name
That works, but now I want to change the database this way, so we dont
the first_name and last_name anymore:
I could create a migration having a name:string:index field.
but after that - how can I make all the first_name and last_name applied
there, and remove the first_name and last_name fields?
- same for appointments:
We had a start_datetime and an end_datetime which until now was enaugh.
but now we want to change it to
planned_start_time end actual_start_time (same for end time)
on the migration all the old data from start_datetime should be put into
both (for historical data) planned end actual times. For the future
How can I make this migrations?
If I know about that later there will be some table changes, but maybe I
understand the routines for that.
Is there also any sql way doing it with rails? For sql itself it would
easy with INSERT…SELECT, so maybe I could generate migrations with sql