Sha256: d3571be9925dfa29a02db4fde632168feb99ce211a02c796c473d1f91b5a6556

Contents?: true

Size: 1.08 KB

Versions: 28

Compression:

Stored size: 1.08 KB

Contents

require 'rails/generators/active_record'

class NotifyUser::JsonUpdateGenerator < Rails::Generators::Base
  include Rails::Generators::Migration

  source_root File.expand_path('../templates', __FILE__)

  def copy_migrations
    copy_migration "add_json_column_to_notifications"
    copy_migration "move_params_to_json"

    puts "Installation successful. You can now run:"
    puts "  rake db:migrate"
  end

  # This is defined in ActiveRecord::Generators::Base, but that inherits from NamedBase, so it expects a name argument
  # which we don't want here. So we redefine it here. Yuck.
  def self.next_migration_number(dirname)
    if ActiveRecord::Base.timestamped_migrations
      Time.now.utc.strftime("%Y%m%d%H%M%S%L%N")
    else
      "%.3d" % (current_migration_number(dirname) + 1)
    end
  end

  protected

    def copy_migration(filename)
      if self.class.migration_exists?("db/migrate", "#{filename}")
        say_status("skipped", "Migration #{filename}.rb already exists")
      else
        migration_template "#{filename}.rb", "db/migrate/#{filename}.rb"
      end
    end

end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
notify_user-0.3.2 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.3.1 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.1.4 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.1.3 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.1.2 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.1.1 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.30 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.29 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.28 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.27 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.26 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.25 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.24 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.23 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.22 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.20 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.19 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.18 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.16 lib/generators/notify_user/json_update/json_update_generator.rb
notify_user-0.0.15 lib/generators/notify_user/json_update/json_update_generator.rb