aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-09-29 10:15:18 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-09-29 10:36:32 -0700
commitb2979117e0adad6f86370074237f57d96cc7c1c7 (patch)
tree8a48ba7f29c39bfd3fc8632d2aa4b778807dac79 /activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
parent2cc4b7f2978b3e2dac490894b5d548c7f58c587e (diff)
downloadrails-b2979117e0adad6f86370074237f57d96cc7c1c7.tar.gz
rails-b2979117e0adad6f86370074237f57d96cc7c1c7.tar.bz2
rails-b2979117e0adad6f86370074237f57d96cc7c1c7.zip
use inheritence to deal with custom methods
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index ce6782aac7..4e770c37da 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -151,10 +151,10 @@ module ActiveRecord
#
# See also TableDefinition#column for details on how to create columns.
def create_table(table_name, options = {})
- table_definition = TableDefinition.new(self)
- table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name.to_s.singularize)) unless options[:id] == false
+ td = table_definition
+ td.primary_key(options[:primary_key] || Base.get_primary_key(table_name.to_s.singularize)) unless options[:id] == false
- yield table_definition if block_given?
+ yield td if block_given?
if options[:force] && table_exists?(table_name)
drop_table(table_name, options)
@@ -162,7 +162,7 @@ module ActiveRecord
create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE "
create_sql << "#{quote_table_name(table_name)} ("
- create_sql << table_definition.to_sql
+ create_sql << td.to_sql
create_sql << ") #{options[:options]}"
execute create_sql
end
@@ -534,6 +534,11 @@ module ActiveRecord
def options_include_default?(options)
options.include?(:default) && !(options[:null] == false && options[:default].nil?)
end
+
+ private
+ def table_definition
+ TableDefinition.new(self)
+ end
end
end
end