Module: Sunrise::Utils::Mysql::ClassMethods
- Defined in:
- lib/sunrise/utils/mysql.rb
Instance Method Summary collapse
-
#disable_keys ⇒ Object
Disables key updates for model table.
-
#enable_keys ⇒ Object
Enables key updates for model table.
-
#truncate! ⇒ Object
Deletes all rows in table very fast, but without calling
destroy
method nor any hooks. -
#with_keys_disabled ⇒ Object
Disables keys, yields block, enables keys.
Instance Method Details
#disable_keys ⇒ Object
Disables key updates for model table
17 18 19 |
# File 'lib/sunrise/utils/mysql.rb', line 17 def disable_keys connection.execute("ALTER TABLE #{quoted_table_name} DISABLE KEYS") end |
#enable_keys ⇒ Object
Enables key updates for model table
22 23 24 |
# File 'lib/sunrise/utils/mysql.rb', line 22 def enable_keys connection.execute("ALTER TABLE #{quoted_table_name} ENABLE KEYS") end |
#truncate! ⇒ Object
Deletes all rows in table very fast, but without calling destroy
method nor any hooks.
12 13 14 |
# File 'lib/sunrise/utils/mysql.rb', line 12 def truncate! transaction { connection.execute("TRUNCATE TABLE #{quoted_table_name};") } end |
#with_keys_disabled ⇒ Object
Disables keys, yields block, enables keys.
27 28 29 30 31 |
# File 'lib/sunrise/utils/mysql.rb', line 27 def with_keys_disabled disable_keys yield enable_keys end |