Sha256: c35e4f51f055d9b71dffb2b16b0c4dd86d18f3d6503f468bb5abb9f8ae7a19c8

Contents?: true

Size: 938 Bytes

Versions: 6

Compression:

Stored size: 938 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 connection.table_exists?(table_name)

      migration_pending_warning!
      false
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
good_job-3.15.12 app/models/good_job/base_record.rb
good_job-3.15.11 app/models/good_job/base_record.rb
good_job-3.15.10 app/models/good_job/base_record.rb
good_job-3.15.9 app/models/good_job/base_record.rb
good_job-3.15.8 app/models/good_job/base_record.rb
good_job-3.15.7 app/models/good_job/base_record.rb