Sha256: 31cae0057f6dd3353c03b88a03cf0b22d4d389ce4a1f26436d8856b9ce47579f

Contents?: true

Size: 946 Bytes

Versions: 45

Compression:

Stored size: 946 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!
      ActiveSupport::Deprecation.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 connection.table_exists?(table_name)

      migration_pending_warning!
      false
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
good_job-3.4.4 app/models/good_job/base_record.rb
good_job-3.4.3 app/models/good_job/base_record.rb
good_job-3.4.2 app/models/good_job/base_record.rb
good_job-3.4.1 app/models/good_job/base_record.rb
good_job-3.4.0 app/models/good_job/base_record.rb