Sha256: 3e4b480b3cf85d0a440ea2d13ceed7c9fedf984cc5f043e2684da6164c0889ab

Contents?: true

Size: 929 Bytes

Versions: 12

Compression:

Stored size: 929 Bytes

Contents

require "rails/generators/active_record"
require "rails/version"
module Github
  module Ds
    module Generators
      class ActiveRecordGenerator < ::Rails::Generators::Base
        include ::Rails::Generators::Migration
        desc "Generates migration for KV table"

        source_paths << File.join(File.dirname(__FILE__), "templates")

        def create_migration_file
          migration_template "migration.rb", "db/migrate/create_key_values_table.rb", migration_version: migration_version
        end

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

        def self.migration_version
          if Rails.version.start_with?('5')
            "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
          end
        end

        def migration_version
          self.class.migration_version
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
github-ds-0.3.0 lib/generators/github/ds/active_record_generator.rb
github-ds-0.2.11 lib/generators/github/ds/active_record_generator.rb
github-ds-0.2.10 lib/generators/github/ds/active_record_generator.rb
github-ds-0.2.9 lib/generators/github/ds/active_record_generator.rb
github-ds-0.2.8 lib/generators/github/ds/active_record_generator.rb
github-ds-0.2.7 lib/generators/github/ds/active_record_generator.rb
github-ds-0.2.6 lib/generators/github/ds/active_record_generator.rb
github-ds-0.2.5 lib/generators/github/ds/active_record_generator.rb
github-ds-0.2.4 lib/generators/github/ds/active_record_generator.rb
github-ds-0.2.3 lib/generators/github/ds/active_record_generator.rb
github-ds-0.2.2 lib/generators/github/ds/active_record_generator.rb
github-ds-0.2.1 lib/generators/github/ds/active_record_generator.rb