Skip to content

2.0 Upgrade Guide

Piotr Solnica edited this page Sep 18, 2017 · 1 revision

Upgrading 1.0.0 => 2.0.0

There were a couple of breaking changes in 2.0.0 and API deprecations in rom-sql 0.8.0.

No more MRI 2.0.0

We dropped support for MRI 2.0.0 as it caused too much friction in the development; however, if you're stuck on MRI 2.0.0 and would like to use rom-rb, please let us know, it'll be easy to add the support back.

ROM.env is gone in rom 2.0.0

If you rely on global ROM.env it's time to stop, rom-rails still provides that but it's gone in rom core gem. Check out rom-rails-skeleton which uses dry-container to manage rom components. You may also want to see how this is done in a more advanced fashion in Icelab's berg project if you'd like to see a non-rails example.

Result from command graphs are no longer instances of Relation::Loaded in rom 2.0.0

If you use custom command graphs, you will notice that now they return either Hash or Array<Hash>, in 1.0.0 they returned Relation::Loaded which was an inconsistent behavior, that's why it was changed.

To upgrade, simply remove calls to #one or #to_a on results from command graphs, ie:

# in 1.0.0:
one_result_command_graph.call(data).one
many_result_command_graph.call(data).to_a

# in 2.0.0
one_result_command_graph.call(data)
many_result_command_graph.call(data)

Command validator setting is deprecated in rom 2.0.0

If you use validator setting in custom command classes, please move this to the application layer and validate data prior sending them to command. We recommend using dry-validation and for complex form handling check out reform.

Command#change is deprecated in rom-sql 0.8.0

This feature is deprecated as we're moving to repository changesets instead. See the user docs for more information