Sha256: 0b5aa296ac5b98d2c54cc7f38c58320de54829301ed694145cfbad44ef78c97b

Contents?: true

Size: 982 Bytes

Versions: 25

Compression:

Stored size: 982 Bytes

Contents

require "rails/generators"
require "rails/generators/active_record"

module MasterDataTool
  class InstallGenerator < ::Rails::Generators::Base
    include ::Rails::Generators::Migration

    source_root File.expand_path("templates", __dir__)

    def self.next_migration_number(dirname)
      ::ActiveRecord::Generators::Base.next_migration_number(dirname)
    end

    def create_migration_file
      migration_dir = File.expand_path("db/migrate")
      template = 'create_master_data_statuses'

      if self.class.migration_exists?(migration_dir, template)
        ::Kernel.warn "Migration already exists: #{template}"
      else
        migration_template(
          "#{template}.rb.erb",
          "db/migrate/#{template}.rb",
          migration_version: migration_version
        )
      end
    end

    private

    def migration_version
      format(
        "[%d.%d]",
        ActiveRecord::VERSION::MAJOR,
        ActiveRecord::VERSION::MINOR
      )
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
master_data_tool-0.23.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.22.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.21.1 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.21.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.20.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.19.1 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.19.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.18.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.17.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.16.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.15.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.14.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.13.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.12.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.11.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.10.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.9.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.8.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.7.0 lib/generators/master_data_tool/install/install_generator.rb
master_data_tool-0.6.0 lib/generators/master_data_tool/install/install_generator.rb