Sha256: 793dd5e0c39bbd3438abb42a83951ec0ad19e7f8fa0bc83a6406244b5f37786b

Contents?: true

Size: 739 Bytes

Versions: 4

Compression:

Stored size: 739 Bytes

Contents

# frozen_string_literal: true

module RedminePluginsHelper
  class Migration
    require_sub __FILE__, include_modules: true

    PLUGIN_ID_CORE_VALUE = :_core_

    common_constructor :plugin_id, :version do
      self.plugin_id = plugin_id.to_sym
      self.version = version.to_i
    end

    # @return [Boolean]
    def applied?
      ::ActiveRecord::SchemaMigration.create_table
      ::ActiveRecord::SchemaMigration.where(version: database_version).any?
    end

    # @return [String]
    def database_version
      core? ? version.to_s : "#{version}-#{plugin_id}"
    end

    # @return [Boolean]
    def core?
      plugin_id == PLUGIN_ID_CORE_VALUE
    end

    # @return [Boolean]
    def plugin?
      !core?
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redmine_plugins_helper-0.13.0 lib/redmine_plugins_helper/migration.rb
redmine_plugins_helper-0.12.2 lib/redmine_plugins_helper/migration.rb
redmine_plugins_helper-0.12.1 lib/redmine_plugins_helper/migration.rb
redmine_plugins_helper-0.12.0 lib/redmine_plugins_helper/migration.rb