class DraftApprove::Generators::MigrationGenerator

Public Class Methods

next_migration_number(path) click to toggle source
# File lib/generators/draft_approve/migration/migration_generator.rb, line 21
def self.next_migration_number(path)
  next_migration_number = current_migration_number(path) + 1
  ActiveRecord::Migration.next_migration_number(next_migration_number)
end

Public Instance Methods

create_migration_file() click to toggle source
# File lib/generators/draft_approve/migration/migration_generator.rb, line 13
def create_migration_file
  migration_template(
    'create_draft_approve_tables.rb',
    'db/migrate/create_draft_approve_tables.rb',
    { migration_version: migration_version, json_type: json_type }
  )
end

Private Instance Methods

json_type() click to toggle source
# File lib/generators/draft_approve/migration/migration_generator.rb, line 32
def json_type
  if [:postgresql, :postgis].include? ActiveRecord::Base.connection.adapter_name.downcase.to_sym
    'jsonb'
  else
    'json'
  end
end
migration_version() click to toggle source
# File lib/generators/draft_approve/migration/migration_generator.rb, line 28
def migration_version
  "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
end