1
0
Fork 0

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

View File

@ -1,4 +1,5 @@
require "burden_web/engine" require 'burden'
require 'burden_web/engine'
module BurdenWeb module BurdenWeb
end end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130606131532) do ActiveRecord::Schema.define(:version => 20130607070108) do
create_table "burden_runs", :force => true do |t| create_table "burden_runs", :force => true do |t|
t.string "name" t.string "name"

1
dummy Symbolic link
View File

@ -0,0 +1 @@
burden_web/spec/dummy

View File

@ -8,6 +8,8 @@ require 'burden/storage'
require 'burden/version' require 'burden/version'
require 'burden/wrapper' require 'burden/wrapper'
# require 'generators/burden/install_generator'
module Burden module Burden
include Config::Helper include Config::Helper

View File

@ -1,22 +0,0 @@
require 'rails/generators'
require 'rails/generators/migration'
class BurdenGenerator < Rails::Generators::Base
include Rails::Generators::Migration
def self.source_root
@source_root ||= File.dirname(__FILE__)
end
def self.next_migration_number(dirname)
if ActiveRecord::Base.timestamped_migrations
Time.new.utc.strftime('%Y%m%d%H%M%S')
else
'%.3d' % (current_migration_number(dirname) + 1)
end
end
def create_migration_file
migration_template 'create_burden_runs.rb', 'db/migrate/create_burden_runs.rb'
end
end

View File

@ -0,0 +1,8 @@
Description:
Explain the generator
Example:
rails generate install Thing
This will create:
what/will/it/create

View File

@ -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

View File

@ -1,5 +1,5 @@
class CreateBurdenRuns < ActiveRecord::Migration class CreateBurdenRuns < ActiveRecord::Migration
def up def self.up
create_table :burden_runs do |t| create_table :burden_runs do |t|
t.string :name t.string :name
t.boolean :success t.boolean :success
@ -8,7 +8,7 @@ class CreateBurdenRuns < ActiveRecord::Migration
end end
end end
def down def self.down
drop_table :burden_runs drop_table :burden_runs
end end
end end