Permalink
Browse files

Only increase text field size for mysql.

  • Loading branch information...
1 parent 3eff5bf commit ac67a5de15e0bcab8ce5ff3c01100620ef577fff @cantino cantino committed Mar 25, 2013
Showing with 14 additions and 4 deletions.
  1. +14 −4 db/migrate/20130126080736_change_memory_to_long_text.rb
@@ -1,11 +1,21 @@
+# PG allows arbitrarily long text fields but MySQL has default limits. Make those limits larger if we're using MySQL.
+
class ChangeMemoryToLongText < ActiveRecord::Migration
def up
- change_column :agents, :memory, :text, :limit => 4294967295
- change_column :events, :payload, :text, :limit => 16777215
+ if mysql?
+ change_column :agents, :memory, :text, :limit => 4294967295
+ change_column :events, :payload, :text, :limit => 16777215
+ end
end
def down
- change_column :agents, :memory, :text, :limit => 65535
- change_column :events, :payload, :text, :limit => 65535
+ if mysql?
+ change_column :agents, :memory, :text, :limit => 65535
+ change_column :events, :payload, :text, :limit => 65535
+ end
+ end
+
+ def mysql?
+ ActiveRecord::Base.connection.adapter_name =~ /mysql/i
end
end

1 comment on commit ac67a5d

Contributor

robertjwhitney commented on ac67a5d Mar 27, 2013

oh that's dope.

Please sign in to comment.