aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2015-09-13 16:24:38 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-01-05 10:36:37 +0900
commit4d4239f980a42d78d3a11b78401c211f0420040d (patch)
tree0f0c7a0e6a67559a1c31a15b644fda40b6010c2c /activerecord/lib
parent35dd9e9f2a10d9d2f46d1c1cdd1df73f7d343d6e (diff)
downloadrails-4d4239f980a42d78d3a11b78401c211f0420040d.tar.gz
rails-4d4239f980a42d78d3a11b78401c211f0420040d.tar.bz2
rails-4d4239f980a42d78d3a11b78401c211f0420040d.zip
Add short-hand methods for text and blob types in MySQL
In Pg and Sqlite3, `:text` and `:binary` have variable unlimited length. But in MySQL, these have limited length for each types (ref #21591, #21619). This change adds short-hand methods for each text and blob types. Example: create_table :foos do |t| t.tinyblob :tiny_blob t.mediumblob :medium_blob t.longblob :long_blob t.tinytext :tiny_text t.mediumtext :medium_text t.longtext :long_text end
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb
index ca7dfda80d..157e75dbf7 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb
@@ -11,6 +11,30 @@ module ActiveRecord
args.each { |name| column(name, :blob, options) }
end
+ def tinyblob(*args, **options)
+ args.each { |name| column(name, :tinyblob, options) }
+ end
+
+ def mediumblob(*args, **options)
+ args.each { |name| column(name, :mediumblob, options) }
+ end
+
+ def longblob(*args, **options)
+ args.each { |name| column(name, :longblob, options) }
+ end
+
+ def tinytext(*args, **options)
+ args.each { |name| column(name, :tinytext, options) }
+ end
+
+ def mediumtext(*args, **options)
+ args.each { |name| column(name, :mediumtext, options) }
+ end
+
+ def longtext(*args, **options)
+ args.each { |name| column(name, :longtext, options) }
+ end
+
def json(*args, **options)
args.each { |name| column(name, :json, options) }
end