Module: IndexedSearch::ResetTable

Included in:
Entry, Word
Defined in:
lib/indexed_search/reset_table.rb

Overview

Just a couple ways of clearing and resetting a table.

Instance Method Summary collapse

Instance Method Details

#reset_auto_incrementObject

if a table has no rows, reset its auto increment



9
10
11
# File 'lib/indexed_search/reset_table.rb', line 9

def reset_auto_increment
  connection.execute("ALTER TABLE #{table_name} AUTO_INCREMENT = 1") if count == 0
end

#truncate_tableObject

do a quick truncate on the table (removes all rows and resets auto increment both)



14
15
16
# File 'lib/indexed_search/reset_table.rb', line 14

def truncate_table
  connection.execute("TRUNCATE TABLE #{table_name}")
end