Some utilities for managing migrations with PostgreSQL
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Nomadize is a collection of rake tasks for managing migrations using a PostgreSQL database. It does not import an entire ORM and aims to be a small / simple utility.


Add this line to your application's Gemfile:

gem 'nomadize'

And then execute:

$ bundle

Or install it yourself as:

$ gem install nomadize


Nomadize supports two different methods for configuring the connection to Postgres. Nomadize will also provide access to the underlying PG connection wrapper (using your defined config) by using the Nomadize::Config.db method. This wrapper responds to exec in the same way that the underlying PG connection object does.

Config File

You may use a config file config/database.yml. This file can be generated with either the rake task: db:generate_template_config or the CLI: $ nomadize generate_template_config. You can also choose to create the file for yourself. config/database.yml should look something like:

  :dbname: lol_dev
  :dbname: lol_test
  :dbname: lol_production

The test/development/production keys define environment dependent options for the PG.connection based on the environment set via RACK_ENV. These key/value pairs are handed directly to the PG.connect method, documentation for what options can be passed can be found here.


As of 0.4.0 Nomadize will also respect the DATABASE_URL environment variable. If DATABASE_URL is set it will override the connection information in the config file config/database.yml. eg postgres://user1:supersecure@somehost:1337/database-name will result in the following configuration hash being passed to the underlying PG.connection object.

  dbname:   'database-name',
  port:     1337,
  user:     'user1',
  password: 'supersecure',
  host:     'somehost'


After a config file is in place add require 'nomadize/tasks' to your rake file, and enjoy helpful new rake tasks such as:

  • rake db:create - creates a database and a schema_migrations table
  • rake db:drop - dumps your poor poor database
  • rake db:new_migration[migration_name] - creates a timestamped migration file in db/migrations/ just fill in the details.
  • rake db:migrate - runs migrations found in db/migrations that have not been run yet
  • rake db:status - see which migrations have or have not been run
  • rake db:rollback[count] - rollback migrations (default count: 1)
  • rake db:generate_template_config - generate a config file in config/database.yml

Alternatively you can use the commandline tool nomadize:

  • nomadize create - creates a database and a schema_migrations table
  • nomadize drop - dumps your poor poor database
  • nomadize new_migration $migration_name - creates a timestamped migration file in db/migrations/ just fill in the details.
  • nomadize migrate - runs migrations found in db/migrations that have not been run yet
  • nomadize status - see which migrations have or have not been run
  • nomadize rollback $count - rollback migrations (default count: 1)
  • nomadize generate_template_config - generate a config file in config/database.yml

Migrations are written in SQL in the generated YAML files:

:up:   'CREATE TABLE testing (field TEXT);'
:down: 'DROP TABLE testing;'



  • an actual config setup / object
  • sql cleaning (getting rid of the interpolation)
  • to display migration status
  • migration rollbacks
  • transactions / error handling
  • maybe some kind of logging idk
  • possibly wrap pg
  • template config file generator
  • maybe set a default migrations path (so the key isn't required in the config file)


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the MIT License.



  • Make migrations path hard coded (this fixes an issue with heroku overwriting the database.yml file)


  • Fix a bug with command line utility using and incorrect method name.


  • support DATABASE_URL env variable
  • Add template_config generator to command line tool
  • Update the README
  • Added some basic logging
  • Fix an issue with rollback count not actually working :'(


  • Include a command line interface for Nomadize commands (THANKS @moonglum)


  • migration_path setting now has a default instead of being a required option in config/database.yml
  • Reworded some of the
  • Added a rake task to generate a template config file in config/database.yml

0.1.0 - Initial Release