Upgrade Notes: v0.9.0
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.rbas shown belowEdit
lib/bookshelf.rbas shown belowEdit
spec/spec_helper.rb, by replacingHanami::Application.preload!withHanami.bootEdit
spec/spec_helper.rb, by addingHanami::Utils.require!("spec/support")(optional)Edit
spec/features_helper.rb, by replacingCapybara.app = Hanami::Container.newwithCapybara.app = Hanami.appEdit
config.ru, by replacingrun Hanami::Container.newwithrun Hanami.appEdit each single application configuration (eg
apps/web/application.rb) by replacingdigestwithfingerprintinassetsblock(s)Remove custom subclasses of
Hanami::Model::Coercer(if any), as PostgreSQL types are now natively supportedEdit all the repositories (
lib/bookshelf/repositories) to inherit fromHanami::Repositoryinstead of including itEdit all the entities (
lib/bookshelf/entities) to inherit fromHanami::Entityinstead of including itEdit 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
require 'bundler/setup'
require 'hanami/setup'
require 'hanami/model' # Add this line
require_relative '../lib/bookshelf'
require_relative '../apps/web/application'
# This used to be `Hanami::Container.configure`, now it must be `Hanami.configure`
Hanami.configure do
mount Web::Application, at: '/'
# This is a new block
#
# Cut and paste the contents of `Hanami::Model.configure` from lib/bookshelf.rb
model do
# This used to be:
#
# adapter type: :sql, url: ENV['DATABASE_URL']
adapter :sql, ENV['DATABASE_URL']
migrations 'db/migrations'
schema 'db/schema.sql'
#
# Mapping block isn't supported anymore
#
end
# This is a new block
#
# Cut and paste the contents of `Hanami::Mailer.configure` from lib/bookshelf.rb
mailer do
# Adjust the new layer `root` location
root Hanami.root.join("lib", "bookshelf", "mailers")
delivery do
development :test
test :test
# production :smtp, address: ENV['SMTP_PORT'], port: 1025
end
end
endlib/bookshelf.rb
# This line is enough ;)
Hanami::Utils.require!("lib/bookshelf")If you have any problem, don’t hesitate to look for help in chat.