0.06
No release in over 3 years
Low commit activity in last 3 years
lazy_migrate lets you easily see which migrations have and have not been run, and makes it easy to up/down/migrate/rollback your migrations through a terminal UI. You can even bump migration versions in the event that you've just pulled master and somebody else merged their migration before yours.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 3.9.0
~> 6.0.3
~> 13.0
~> 3.0
>= 0
~> 1.4.2

Runtime

 Project Readme

LazyMigrate

Easily manage rails migrations with a mini UI that can be invoked in your console or on the command line.

I am sick and tired of having to manually copy and paste version numbers from my migration filenames whenever I have to do anything more complicated than rails db:migrate! So I made a gem that easily plugs into a rails app and makes it all a little easier.

Although most of this just forwards the commands directly to rails, one feature goes a step beyond. If you have ever pulled the latest changes on master only to find that somebody managed to merge a migration before you merged yours, you may be familiar with the dance of:

  1. down'ing your migration
  2. obtaining a new version timestamp
  3. replacing the version in your migration's filename
  4. up'ing the migration again

This gem lets you do all that with the press of a button (via the bring to top option), so you don't need to break a sweat trying to merge your migration before somebody else beats you to the punch.

Installation

Add this line to your application's Gemfile:

gem 'lazy_migrate'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install lazy_migrate

Usage

From within a rails console, go

LazyMigrate.run

You can also invoke lazy_migrate as a rake task either by adding the following to your Rails app Rakefile:

spec = Gem::Specification.find_by_name('lazy_migrate')
load "#{spec.gem_dir}/lib/tasks/lazy_migrate.rake"

Or by creating a rake task yourself like so:

# in lib/tasks/lazy_migrate.rake
# frozen_string_literal: true

require 'lazy_migrate'

namespace :lazy_migrate do
  desc 'runs lazy_migrate'
  task run: :environment do
    LazyMigrate.run
  end
end

Development

After checking out the repo, run bin/setup to install dependencies.

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 rubygems.org.

We use Appraisal to test the gem against different rails version like so:

bundle exec appraisal

bundle exec appraisal rails_5_1_5 rspec
bundle exec appraisal rails_5_2_4_3 install

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jesseduffield/lazy_migrate. If anybody wants this to work with the Data Migrate gem let me know, currently it's only for schema migrations. Hope you like types! Cos this gem uses Sorbet.

License

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