This gem is designed to replace the
hanami-model one in your
Hanami project. It adds an equivalent set of database
commands to the
hanami executable, and generates Sequel models.
Please note that using this gem could be considered bad practice with regards to Hanami’s architectural goals, as it does not provide any help to separate the model into entities and repositories. On the other hand, it does nothing to prevent it either.
Follow the instructions for removing
Use Your Own ORM
Add this line to your
Add this line to your application’s Gemfile (adding the gem to the
group ensures that the
hanami executable is correctly extended):
group :plugins do gem 'hanami-sequel', '~> 1.1.0' end
And then execute:
This gem’s version is based on the major and minor versions of Hanami. For
hanami-sequel-X.Y.P. This gem’s patch version (denoted as
P) is independent from Hanami’s patch version (denoted as
As of now, the paths to migrations and models are hardcoded respectively to
All the commands start with the
Commands: hanami sequel create hanami sequel drop hanami sequel install hanami sequel migrate [VERSION] hanami sequel migration NAME hanami sequel model NAME hanami sequel seed
Create a database table
$ hanami sequel model NAME
NAME is the name of the model. This creates a database migration, a
Sequel model and a spec file. Additionally, a Sequel spec helper file will be
created if none exists.
Create a database migration
$ hanami sequel migration NAME
NAME is an arbitrary name.
Create the database
$ hanami sequel create
This command will fail in the
Migrate the database
$ hanami sequel migrate [VERSION]
VERSION can be:
- "up" (default value), to do all the migrations, i.e.
hanami sequel migrateor
hanami sequel migrate up.
- "down", to undo all the migrations, i.e.
hanami sequel migrate down.
- a timestamp, representing the first part of the target migration file. E.g.
hanami sequel migrate 20180201153930to migrate to the database version as of 1st February 2018 at 15:39:30 (if a migration file starting with this value is found).
Seed the database
$ hanami sequel seed
This command will look up your models for
Hanami:Sequel:Seed class methods
used to import constants into your tables. If an error occurs, the whole
operation will be rolled back.
Drop the database
$ hanami sequel drop
This command will fail in the
Install the database
$ hanami sequel install
seeds your database. It
will fail in the
After checking out the repo, run
bin/setup to install dependencies. Then, run
rake spec to run the tests. You can also run
bin/console for an interactive
prompt that will allow you to experiment.
To install this gem onto your local machine, run
bundle exec rake install. To
release a new version, update the version number in
version.rb, and then run
bundle exec rake release, which will create a git tag for the version, push
git commits and tags, and push the
.gem file to
Known issues / To-do list
- hardcoded configuration values
- no tests
Bug reports and pull requests are welcome on GitHub at https://github.com/malin-as/hanami-sequel.