• Use Ruby 2.3+

  • Edit Gemfile, by changing Hanami version: gem 'hanami', '~> 0.9'

  • Edit Gemfile, by changing Hanami Model version: gem 'hanami-model', '~> 0.7'

  • Edit config/environment.rb as shown below

  • Edit lib/bookshelf.rb as shown below

  • Edit spec/spec_helper.rb, by replacing Hanami::Application.preload! with Hanami.boot

  • Edit spec/spec_helper.rb, by adding Hanami::Utils.require!("spec/support") (optional)

  • Edit spec/features_helper.rb, by replacing Capybara.app = Hanami::Container.new with Capybara.app = Hanami.app

  • Edit config.ru, by replacing run Hanami::Container.new with run Hanami.app

  • Edit each single application configuration (eg apps/web/application.rb) by replacing digest with fingerprint in assets block(s)

  • Remove custom subclasses of Hanami::Model::Coercer (if any), as PostgreSQL types are now natively supported

  • Edit all the repositories (lib/bookshelf/repositories) to inherit from Hanami::Repository instead of including it

  • Edit all the entities (lib/bookshelf/entities) to inherit from Hanami::Entity instead of including it

  • Edit all the repositories by moving the class level methods to instance level

  • Update all the repositories with the new syntax

  • Edit all the entities by removing .attributes

config/environment.rb

  1. require 'bundler/setup'
  2. require 'hanami/setup'
  3. require 'hanami/model' # Add this line
  4. require_relative '../lib/bookshelf'
  5. require_relative '../apps/web/application'
  6. # This used to be `Hanami::Container.configure`, now it must be `Hanami.configure`
  7. Hanami.configure do
  8. mount Web::Application, at: '/'
  9. # This is a new block
  10. #
  11. # Cut and paste the contents of `Hanami::Model.configure` from lib/bookshelf.rb
  12. model do
  13. # This used to be:
  14. #
  15. # adapter type: :sql, url: ENV['DATABASE_URL']
  16. adapter :sql, ENV['DATABASE_URL']
  17. migrations 'db/migrations'
  18. schema 'db/schema.sql'
  19. #
  20. # Mapping block isn't supported anymore
  21. #
  22. end
  23. # This is a new block
  24. #
  25. # Cut and paste the contents of `Hanami::Mailer.configure` from lib/bookshelf.rb
  26. mailer do
  27. # Adjust the new layer `root` location
  28. root Hanami.root.join("lib", "bookshelf", "mailers")
  29. delivery do
  30. development :test
  31. test :test
  32. # production :smtp, address: ENV['SMTP_PORT'], port: 1025
  33. end
  34. end
  35. end

lib/bookshelf.rb

  1. # This line is enough ;)
  2. Hanami::Utils.require!("lib/bookshelf")

If you have any problem, don’t hesitate to look for help in chat.