I recently tried to retrofit STI on a database table that had already existed for a while. Here's a basic outline of the scenario.
- I had a class 'Code' and a database table 'codes'.
- 'Code' had an attribute 'units', which could be either '$' or '%'
- I wanted the STI classes to be Code::Dollar or Code::Percent
I successfully implemented this with the following:
class Code