diff --git a/lib/generators/active_record/create_rake_control_runs.rb b/lib/generators/active_record/create_rake_control_runs.rb new file mode 100644 index 0000000..4e86c5a --- /dev/null +++ b/lib/generators/active_record/create_rake_control_runs.rb @@ -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 diff --git a/lib/generators/active_record/rake_control_generator.rb b/lib/generators/active_record/rake_control_generator.rb new file mode 100644 index 0000000..ca28c72 --- /dev/null +++ b/lib/generators/active_record/rake_control_generator.rb @@ -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 diff --git a/lib/rake_control/storage/activerecord/rake_control_run.rb b/lib/rake_control/storage/activerecord/rake_control_run.rb new file mode 100644 index 0000000..113fb95 --- /dev/null +++ b/lib/rake_control/storage/activerecord/rake_control_run.rb @@ -0,0 +1,5 @@ +module RakeControl + class Run < ActiveRecord::Base + attr_accessible :name, :success, :execution_time + end +end