Migration generator

This commit is contained in:
Gregory Eremin
2013-06-07 11:01:57 +04:00
parent 53b0645b8d
commit af16ec0982
9 changed files with 36 additions and 26 deletions
@@ -0,0 +1,8 @@
Description:
Explain the generator
Example:
rails generate install Thing
This will create:
what/will/it/create
@@ -0,0 +1,20 @@
require 'rails/generators'
require 'rails/generators/migration'
module Burden
module Generators
class InstallGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('../templates', __FILE__)
def self.next_migration_number(path)
Time.now.utc.strftime("%Y%m%d%H%M%S")
end
def create_migration
migration_template 'create_burden_runs.rb', 'db/migrate/create_burden_runs.rb'
end
end
end
end
@@ -0,0 +1,14 @@
class CreateBurdenRuns < ActiveRecord::Migration
def self.up
create_table :burden_runs do |t|
t.string :name
t.boolean :success
t.float :execution_time
t.timestamps
end
end
def self.down
drop_table :burden_runs
end
end