notes to self.

The Big Rewrite, Porting a Legacy Application to Rails

  • set your development database to a production database as readonly.
  • dump a schema of your current database using seed_dumper.
  • create a simple model for each table.
  • use safe_attributes to deal with columns with reserved names (ex: hash, type).
  • annotate your models with annotate_models gem.
  • run a desc db.table and paste the result inside the corresponding model.
  • ensure ActiveRecord detect your database columns datatypes correctly or in a compatible (ex: generating the same result).
  • start unit testing your model for the NOT NULL attributes and add validates_presence_of :column_name.
  • configure a code coverage report tool like simpleconv.
  • add self.table_name = 'old_table_name' to each model if not matches rails conventions.
  • add belongs_to according your memory and add tests checking assert #respond_to? :entity not assert #respond_to? :entity_id.
  • spin a rails console help with the tests.
  • add routes test, create route.
  • test your controllers at the boundaries, same input same output.
  • ensure the database are with the same behaviour (ex: NULL, 0).
  • deal with the error paths, return same errors (ex: request with empty or incorrect data, invalid api keys).
  • implement the old cron tasks as a batchable job, execute as a proccess using resque or sidekiq.