Sha256: 2ebfcf08e5aad2da74e54d15b83978a6227aa130a039579659711249135e834c

Contents?: true

Size: 915 Bytes

Versions: 2

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true
module GoodJob
  # Base ActiveRecord class that all GoodJob models inherit from.
  # Parent class can be configured with +GoodJob.active_record_parent_class+.
  # @!parse
  #   class BaseRecord < ActiveRecord::Base; end
  class BaseRecord < Object.const_get(GoodJob.active_record_parent_class)
    self.abstract_class = true

    def self.migration_pending_warning!
      GoodJob.deprecator.warn(<<~DEPRECATION)
        GoodJob has pending database migrations. To create the migration files, run:
            rails generate good_job:update
        To apply the migration files, run:
            rails db:migrate
      DEPRECATION
      nil
    end

    # Checks for whether the schema is up to date.
    # Can be overriden by child class.
    # @return [Boolean]
    def self.migrated?
      return true if table_exists?

      migration_pending_warning!
      false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
good_job-3.15.14 app/models/good_job/base_record.rb
good_job-3.15.13 app/models/good_job/base_record.rb