Module: AbAdmin::Utils::Mysql::ClassMethods
- Defined in:
- lib/ab_admin/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
16 17 18 |
# File 'lib/ab_admin/utils/mysql.rb', line 16 def disable_keys connection.execute("ALTER TABLE #{quoted_table_name} DISABLE KEYS") end |
#enable_keys ⇒ Object
Enables key updates for model table
21 22 23 |
# File 'lib/ab_admin/utils/mysql.rb', line 21 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.
11 12 13 |
# File 'lib/ab_admin/utils/mysql.rb', line 11 def truncate! transaction { connection.execute("TRUNCATE TABLE #{quoted_table_name};") } end |
#with_keys_disabled ⇒ Object
Disables keys, yields block, enables keys.
26 27 28 29 30 |
# File 'lib/ab_admin/utils/mysql.rb', line 26 def with_keys_disabled disable_keys yield enable_keys end |