class ActiveRecord::InternalMetadata
:nodoc:
‘use_metadata_table` to false in your database configuration.
This is enabled by default. To disable this functionality set
as which environment migrations were run in.
This class is used to create a table that keeps track of values and keys such
def [](key)
def [](key) return unless enabled? where(key: key).pick(:value) end
def []=(key, value)
def []=(key, value) return unless enabled? find_or_initialize_by(key: key).update!(value: value) end
def create_table
def create_table return unless enabled? unless connection.table_exists?(table_name) connection.create_table(table_name, id: false) do |t| t.string :key, **connection.internal_string_options_for_primary_key t.string :value t.timestamps end end end
def drop_table
def drop_table return unless enabled? connection.drop_table table_name, if_exists: true end
def enabled?
def enabled? ActiveRecord::Base.connection.use_metadata_table? end
def primary_key
def primary_key "key" end
def table_name
def table_name "#{table_name_prefix}#{internal_metadata_table_name}#{table_name_suffix}" end