default 0000-00-00 00:00:00 datetime columns to 'epoch'
authorJacob Coby <jcoby@portallabs.com>
Fri, 26 Mar 2010 17:35:43 +0000 (13:35 -0400)
committerJacob Coby <jcoby@portallabs.com>
Fri, 26 Mar 2010 17:35:43 +0000 (13:35 -0400)
mysql2psql

index 8f69b1a..a161ee3 100755 (executable)
@@ -385,6 +385,10 @@ EOF
         if column[:type] == "char"
           row[index] = row[index] == 1 ? 't' : row[index] == 0 ? 'f' : row[index]
         end
+        # give a default for zeroed datetimes
+        if column[:type] == "datetime" and row[index] == '0000-00-00 00:00:00'
+          row[index] = 'epoch'
+        end
         if row[index].is_a?(String)
           if column[:type] == "bytea"
             row[index] = PGconn.quote(row[index])