No commit activity in last 3 years
No release in over 3 years
Simple tool for managing database patches
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
>= 0
>= 0
~> 10.0
~> 3.0

Runtime

>= 0
 Project Readme

DatabasePatcher

This is a tool for making database schema changes in our project. This is a CLI tool

This tool has two convention to follow

  • It will use the project_root/db/patches folder for look up any change request
  • It will create and maintain an :installed_patches table

Installation

Add this line to your application's Gemfile:

gem 'database_patcher'

And then execute:

$ bundle

Or install it yourself as:

$ gem install database_patcher

Usage

The following commands supported:

	Command: help
	Description: show command specific help message

	Command: create_patch
	aliases: add, new
	Description: create a new patch file with this tools convention

	Command: initialize
	aliases: init, setup
	Description: this will create initial directory and the default installed_patches table in the database

	Command: apply_pending_patches
	aliases: apply, up
	Description: apply all pending db patch

	Command: execute_all_remove_patch
	aliases: apply, up
	Description: execute the down patches and remove all db patch

	Command: rollback
	aliases: revert, step_back
	Description: execute the last patch down part, and remove the db patch registration

Example use

$ database_patcher create_patch create some test table #> return the patch path

use to edit the file/files

$ database_patcher apply_pending_patches

Here is a cheat sheet if you want use the ruby syntax for creating patches

Rake integration

to use database_patcher from rake you can use the following:

Rakefile

require "database_patcher/rake_task"

$ rake -T

  rake db:apply_pending_patches                      # apply pending schema migrations
  rake db:create_patch[type,idempotent,description]  # create a new migration patch
  rake db:migrate                                    # Alias task for apply_pending_patches
  rake db:revert_installed_patches                   # apply pending schema migrations
  rake db:rollback                                   # rollback one patch