Sha256: 4bb35569b47bb1ceff508788c0ab65c8293ac8598192bf50e4b3467bbf10276c

Contents?: true

Size: 753 Bytes

Versions: 5

Compression:

Stored size: 753 Bytes

Contents

# frozen_string_literal: true

require 'rails'

module DelayedJobPreventDuplicate
  class DelayedJobPreventDuplicateGenerator < ::Rails::Generators::Base

    include Rails::Generators::Migration
    source_root File.expand_path("../templates", __FILE__)

    def self.next_migration_number(path)
      unless @prev_migration_nr
        @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
      else
        @prev_migration_nr += 1
      end
     @prev_migration_nr.to_s
    end

    def copy_migration
      migration_template "migration.rb", "db/migrate/add_signature_to_delayed_job.rb", migration_version: migration_version
    end

    def migration_version
      "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
delayed_job_prevent_duplicate-0.1.4 lib/generators/delayed_job_prevent_duplicate_generator.rb
delayed_job_prevent_duplicate-0.1.3 lib/generators/delayed_job_prevent_duplicate_generator.rb
delayed_job_prevent_duplicate-0.1.2 lib/generators/delayed_job_prevent_duplicate_generator.rb
delayed_job_prevent_duplicate-0.1.1 lib/generators/delayed_job_prevent_duplicate_generator.rb
delayed_job_prevent_duplicate-0.1.0 lib/generators/delayed_job_prevent_duplicate_generator.rb