Module: IndexedSearch::ResetTable
Overview
Just a couple ways of clearing and resetting a table.
Instance Method Summary collapse
-
#reset_auto_increment ⇒ Object
if a table has no rows, reset its auto increment.
-
#truncate_table ⇒ Object
do a quick truncate on the table (removes all rows and resets auto increment both).
Instance Method Details
#reset_auto_increment ⇒ Object
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_table ⇒ Object
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 |