Project

mi

0.01
No commit activity in last 3 years
No release in over 3 years
Mi is a generator of migration file instead of `rails generate migration`.
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.8.13
~> 2.13.0
~> 4.6.5
~> 0.10.3
~> 10.0
~> 3.4.0
~> 0.41.1
~> 0.11.0

Runtime

>= 4.0.0
>= 4.0.0
 Project Readme

Mi

Gem Version Build Status Coverage Status Stories in Ready

mi is a generator of migration file instead of rails generate migration.

  • Simple Syntax
  • Automatically generate class name.

Installation

Add this line to your application's Gemfile:

group :development do
  gem 'mi'
end

And then execute:

$ bundle

Or install it yourself as:

$ gem install mi

Usage

add_column

$ bin/rails g mi users +email:string
      create  db/migrate/20160429062420_add_email_to_users.rb

db/migrate/20160429062420_add_email_to_users.rb

class AddEmailToUsers < ActiveRecord::Migration
  def change
    add_column :users, :email, :string
  end
end

remove_column

$ bin/rails g mi users -email
      create  db/migrate/20160429124502_remove_email_to_users.rb

db/migrate/20160429124502_remove_email_to_users.rb

class RemoveEmailToUsers < ActiveRecord::Migration
  def change
    remove_column :users, :email
  end
end

change_column

$ bin/rails g mi users %email:string:{null:true}
      create  db/migrate/20160429124852_change_email_to_users.rb

db/migrate/20160429124852_change_email_to_users.rb

class ChangeEmailToUsers < ActiveRecord::Migration
  def change
    change_column :users, :email, :string, null: true
  end
end

create_table

$ bin/rails g mi:create users +email:string:{null:false} +name:string
      create  db/migrate/20160704144601_create_users_table.rb

db/migrate/20160704144601_create_users_table.rb

class CreateUsersTable < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :email, null: false
      t.string :name

      t.timestamps null: false
    end
  end
end

Open with editor

Put a --edit option, mi opens the migration file after generated.

$ bin/rails g mi users +email:string --edit

Dependencies

  • Ruby 2.2 or higher
  • Rails 4 or higher

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/pocke/mi.

Links