It’s very rare to directly update from ruby 1.8.7 or ruby 2.0 to ruby 2.7 and rails 4 to rails 6.0. As I have recently done many upgrade projects from legacy ruby code to new ruby code. So, I thought to help other developers too.
How?
To do so, I have got the advantage of working from Ruby 2.x to the current version of ruby to I know each and everything from legacy plugin development age to gems and then gems to new replaced gems(if depreciated).
What?
For a small project, I would rather suggest installing a fresh project in the latest ruby and latest rails there. Now, I will replace the app folder of the old code into a new project.
also, I will keep adding configurations carefully as it’s mainly updated.
GEMS:
Regarding other gems, go to their GitHub documentation and check if the community is active (check using the last commit), if yes then you can install with their latest version without setting the gem version. i.e. gem install devise and add gem 'devise' in your Gemfile.
Migration:
and most important is the GEMS, from the old file, remove all ruby and rails related gems to transfer as new rails is already installed.
In migrations, you will have to add `[6.0]` in migration.
Webpacker update:
Ideally, we should use webpacker with rails 6, but As most clients don’t give time to re-write the javascript code with webpacker. So, It’s better to use normal javascript as in-app/assets folder.
And
For better projects management, we should follow the process:
Prepare the List of Decreciated gems. Identify all possible new gems which can be used also if required or not.
Prepare the documentation of changes required.
Prepare the timelines accordingly.
Work on ROR update as per your plan.
Always use another branch for any kind of upgrades. and never use the master branch for an upgrade.
Try to write the test cases as well so that you will be sure about the functionality is working properly.
Feel free to let me know if you face any issue or wish me to work on your ruby on rails update. I will be happy to assist.
Now, you have `database_name.sql` and try to open the file and search the string `0000-00-00 00:00:00` and replace it with `CURRENT_TIMESTAMP`. You can do that with below command:
sed -i.bu 's/'\''0000-00-00 00:00:00'\''/CURRENT_TIMESTAMP/g' database_name.sql
Once in your file when you replaced all `0000-00-00 00:00:00` with `CURRENT_TIMESTAMP`. You can import that into new separate MySQL 5.7 installed separately successfully.