<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,17 +1,16 @@
-namespace :clear_empty_attributes do
-  desc &quot;clear all blank strings of the given MODELS&quot;
-  task :clear_all_blank_strings do
-    raise &quot;rake clear_empty_attributes:clear_all_blank_strings MODELS=User,Movie,... to clear blank strings of those models&quot; unless ENV['MODELS']
-    models = ENV['MODELS'].split(',').map(&amp;:constantize)
-
-    models.each do |model|
-      puts &quot;#{model}:&quot;
-      model.columns.select(&amp;:text?).each do |column|
+namespace :db do
+  desc &quot;Clear all blank strings in the database. Specify TABLES=table1,table2 to limit to specific tables.&quot;
+  task :clear_empty_attributes =&gt; :environment do
+    connection = ActiveRecord::Base.connection
+    tables = ENV['TABLES'] ? ENV['TABLES'].split(/,/) : connection.tables
+    tables.each do |table|
+      puts &quot;#{table}:&quot;
+      connection.columns(table).select(&amp;:text?).each do |column|
         name = column.name
         puts &quot;  #{name}&quot;
-        model.update_all(&quot;#{name} = NULL&quot;,&quot;#{name} = ''&quot;)
+        column_name = connection.quote_column_name(column.name)
+        connection.update(&quot;UPDATE #{connection.quote_table_name(table)} SET #{column_name} = NULL WHERE #{column_name} = ''&quot;)
       end
-      puts ''
     end
   end
 end
\ No newline at end of file</diff>
      <filename>tasks/clear_empty_attributes.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9c5b43f878e2d26dd3d7bc5e9c2375751190e09c</id>
    </parent>
  </parents>
  <author>
    <name>Brandon Keepers</name>
    <email>brandon@collectiveidea.com</email>
  </author>
  <url>http://github.com/collectiveidea/clear_empty_attributes/commit/e1d504c76e9a133d4f7c89748c6302066cdbd774</url>
  <id>e1d504c76e9a133d4f7c89748c6302066cdbd774</id>
  <committed-date>2009-01-15T22:15:35-08:00</committed-date>
  <authored-date>2009-01-15T22:15:35-08:00</authored-date>
  <message>Rename rake task to db:clear_empty_attributes and refactor to use all tables by default</message>
  <tree>dd979d6a11f968d47b8cad493e756bd923144172</tree>
  <committer>
    <name>Brandon Keepers</name>
    <email>brandon@collectiveidea.com</email>
  </committer>
</commit>
