1
0
Fork 0

ActiveRecord storage draft

This commit is contained in:
Gregory Eremin 2013-06-04 23:56:25 +04:00
parent 639c542aaf
commit 3fc9fba18c
3 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,14 @@
class CreateRakeControlRuns < ActiveRecord::Migration
def self.up
create_table :rake_control_runs do |t|
t.string :name
t.boolean :success
t.float :execution_time
t.timestamps
end
end
def self.down
drop_table :rake_control_runs
end
end

View File

@ -0,0 +1,22 @@
require 'rails/generators'
require 'rails/generators/migration'
class RakeControlGenerator < 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_rake_control_runs.rb', 'db/migrate/create_rake_control_runs.rb'
end
end

View File

@ -0,0 +1,5 @@
module RakeControl
class Run < ActiveRecord::Base
attr_accessible :name, :success, :execution_time
end
end