<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,16 +2,24 @@
 DESCRIPTION
 ===========
 
-Helpers for migrations of ActiveRecord for dealing with foreign keys and primary keys.
+Helpers for migrations of ActiveRecord for dealing with foreign keys and primary keys and more stuff.
 
 FEATURES
 ========
 
  * **foreign keys**
-    * foreign_key(table, field, referenced_table, referenced_field, on_cascade)
-    * drop_foreign_key(table, field)
+    * `foreign_key(table, field, referenced_table, referenced_field, on_cascade)`
+    * `drop_foreign_key(table, field)`
  * **primary keys**
-    * primary_key(table, field)
+    * `primary_key(table, field)`
+ * **repair_tables**
+   * `repair_tables :users, :clients`
+   * `repair_tables` (all tables)
+ * **optimize_tables**
+   * `optimize_tables :readings, :jobs`
+   * `optimize_tables` (all tables)
+ * **each_table**
+   * Yields each table name
 
 Examples
 ========
@@ -33,6 +41,15 @@ Typical use:
       end
 
       foreign_key :users, :profile_id, :profiles
+
+      repair_tables
+      optimize_tables
+
+      each_table do |name|
+        say_with_time &quot;Some operation with #{name}&quot; do
+          #execute &quot;..... #{name}&quot;
+        end
+      end
     end
 
     def self.down</diff>
      <filename>README.markdown</filename>
    </modified>
    <modified>
      <diff>@@ -31,6 +31,41 @@ module MigrationConstraintHelpers
       execute &quot;ALTER TABLE #{table} ADD PRIMARY KEY(#{field_list(field)})&quot;
    end
 
+   # Execute REPAIR TABLE in each table given as parameter or in all of them
+   # if none is indicated
+   #
+   # tables: list of tables
+   def repair_tables(*tables)
+      ActiveRecord::Migration.say(&quot;Reparing tables...&quot;, true)
+      each_table do |table|
+         if tables.empty? || tables.include?(table.to_s)
+            ActiveRecord::Migration.say(table, true)
+            execute &quot;REPAIR TABLE #{table}&quot;
+         end
+      end
+   end
+
+   # Execute OPTIMIZE TABLE in each table given as parameter or in all of them
+   # if none is indicated
+   #
+   # tables: list of tables
+   def optimize_tables(*tables)
+      each_table do |table|
+         if tables.empty? || tables.include?(table.to_s)
+            ActiveRecord::Migration.say(table, true)
+            execute &quot;OPTIMIZE TABLE #{table}&quot;
+         end
+      end
+   end
+
+   # Yields for each table defined in the database
+   # The name of the table is given as parameter
+   def each_table
+      execute(&quot;SHOW TABLES&quot;).each do |a|
+         yield a.values.first
+      end
+   end
+
    private
 
    # Creates a constraint name for table and field given as parameters
@@ -48,4 +83,5 @@ module MigrationConstraintHelpers
    def field_list_name(fields)
       fields.is_a?(Array) ? fields.join('_') : fields
    end
+
 end</diff>
      <filename>lib/migration_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0da23149a371f081774daed6e5f5ac32e810323b</id>
    </parent>
  </parents>
  <author>
    <name>Jes&#250;s Garc&#237;a S&#225;ez</name>
    <email>blaxter@gmail.com</email>
  </author>
  <url>http://github.com/blaxter/migration_helpers/commit/4715e3e05898836503a2817842dc0e65114d6a3a</url>
  <id>4715e3e05898836503a2817842dc0e65114d6a3a</id>
  <committed-date>2009-10-05T10:32:25-07:00</committed-date>
  <authored-date>2009-10-05T10:32:25-07:00</authored-date>
  <message>add repair_tables, optimize_table methods

Also a helper each_table{|table_name| ... } method has been added</message>
  <tree>b82b69c297dc4d870159814ba8a0e8a2e47ae005</tree>
  <committer>
    <name>Jes&#250;s Garc&#237;a S&#225;ez</name>
    <email>blaxter@gmail.com</email>
  </committer>
</commit>
