From 506dabf309c65818c71b23bacbd59b85627ada91 Mon Sep 17 00:00:00 2001 From: Michael Bulat Date: Fri, 24 Jul 2015 11:04:51 -0400 Subject: [PATCH] generator for adding date field to entries --- lib/generators/plutus/add_date_upgrade_generator.rb | 11 +++++++++++ lib/generators/plutus/templates/add_date_migration.rb | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 lib/generators/plutus/add_date_upgrade_generator.rb create mode 100644 lib/generators/plutus/templates/add_date_migration.rb diff --git a/lib/generators/plutus/add_date_upgrade_generator.rb b/lib/generators/plutus/add_date_upgrade_generator.rb new file mode 100644 index 00000000..ec8c5433 --- /dev/null +++ b/lib/generators/plutus/add_date_upgrade_generator.rb @@ -0,0 +1,11 @@ +require 'rails/generators' +require 'rails/generators/migration' +require_relative 'base_generator' + +module Plutus + class AddDateUpgradeGenerator < BaseGenerator + def create_migration_file + migration_template 'add_date_migration.rb', 'db/migrate/add_date_to_plutus_entries.rb' + end + end +end diff --git a/lib/generators/plutus/templates/add_date_migration.rb b/lib/generators/plutus/templates/add_date_migration.rb new file mode 100644 index 00000000..c00bd267 --- /dev/null +++ b/lib/generators/plutus/templates/add_date_migration.rb @@ -0,0 +1,6 @@ +class AddDateToPlutusEntries < ActiveRecord::Migration + def change + add_column :plutus_entries, :date, :date + add_index :plutus_entries, :date + end +end