Support to work with Rails foreien_key implementation

Ref: https://github.com/rails/rails/commit/69c711f38cac85e9c8bdbe286591bf88ef720bfa