Module: NoBrainer::Document::TableConfig

Extended by:
ActiveSupport::Concern, Autoload
Defined in:
lib/no_brainer/document/table_config.rb

Defined Under Namespace

Modules: ClassMethods Classes: Synchronizer

Constant Summary collapse

VALID_TABLE_CONFIG_OPTIONS =
[:name, :durability, :shards, :replicas, :primary_replica_tag, :nonvoting_replica_tags, :write_acks]

Class Method Summary collapse

Methods included from Autoload

autoload, autoload_and_include, eager_autoload, eager_load!, extended

Class Method Details

.drop!Object



119
120
121
# File 'lib/no_brainer/document/table_config.rb', line 119

def drop!
  NoBrainer.run { |r| r.db_drop(NoBrainer.current_db) }
end

.purge!Object



123
124
125
126
127
128
129
130
# File 'lib/no_brainer/document/table_config.rb', line 123

def purge!
  NoBrainer.run { |r| r.table_list }.each do |table_name|
    # keeping the index meta store because indexes are not going away when purging
    next if table_name == NoBrainer::Document::Index::MetaStore.table_name
    NoBrainer.run { |r| r.table(table_name).delete }
  end
  true
end

.rebalance(options = {}) ⇒ Object



112
113
114
115
116
117
# File 'lib/no_brainer/document/table_config.rb', line 112

def rebalance(options={})
  NoBrainer.run { |r| r.table_list }.each do |table_name|
    NoBrainer.run { |r| r.table(table_name).rebalance }
  end
  true
end

.sync_indexes(options = {}) ⇒ Object



101
102
103
104
105
# File 'lib/no_brainer/document/table_config.rb', line 101

def sync_indexes(options={})
  # NoBrainer internal models don't have indexes.
  models = NoBrainer::Document.all(:types => [:user])
  NoBrainer::Document::Index::Synchronizer.new(models).sync_indexes(options)
end

.sync_schema(options = {}) ⇒ Object



107
108
109
110
# File 'lib/no_brainer/document/table_config.rb', line 107

def sync_schema(options={})
  sync_table_config(options)
  sync_indexes(options)
end

.sync_table_config(options = {}) ⇒ Object



96
97
98
99
# File 'lib/no_brainer/document/table_config.rb', line 96

def sync_table_config(options={})
  models = NoBrainer::Document.all(:types => [:user, :nobrainer])
  NoBrainer::Document::TableConfig::Synchronizer.new(models).sync_table_config(options)
end