Skip to content

Instantly share code, notes, and snippets.

@sr75
Created April 15, 2013 15:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sr75/5388805 to your computer and use it in GitHub Desktop.
Save sr75/5388805 to your computer and use it in GitHub Desktop.
mysql 5.6 rails active_record migration text max lengths for a database created with utf8
# just an active_record migration example for reference
# source of this logic: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
class CreateMetaTexts < ActiveRecord::Migration
def up
create_table :meta_texts do |t|
t.text :default_text_63KB, limit: 63.kilobytes # 64512 < 65535 limit for when text datatype changes to mediumtext datatype
t.text :medium_text_64KB, limit: 64.kilobytes # 65536 > 65535 limit and triggers text datatype to mediumtext datatype
t.text :medium_text_15MB, limit: 15.megabytes # 15728640 < 16777215 limit for when mediumtext changes to longtext datatype
t.text :long_text_16MB, limit: 16.megabytes # 16777216 > 16777215 limit and triggers mediumtext datatype to longtext datatype
end
end
def down
drop_table :meta_texts
end
end
=begin
CREATE TABLE `meta_texts` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY,
`default_text_63KB` text,
`medium_text_64KB` mediumtext,
`medium_text_15MB` mediumtext,
`long_text_16MB` longtext) ENGINE=InnoDB
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment