aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-07-04 18:51:02 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-07-04 18:51:02 +0000
commit4160b518a82bcaa84e0e3125b4947b2dc3837fa3 (patch)
treedef4e797e1834c65864498509ea98edd7dad7745 /activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
parent452442dde8e8ea5949c387ea5c78387bff330f2a (diff)
downloadrails-4160b518a82bcaa84e0e3125b4947b2dc3837fa3.tar.gz
rails-4160b518a82bcaa84e0e3125b4947b2dc3837fa3.tar.bz2
rails-4160b518a82bcaa84e0e3125b4947b2dc3837fa3.zip
Added new Migrations framework for describing schema transformations in a way that can be easily applied across multiple databases #1604 [Tobias Luetke]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1672 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract_adapter.rb')
-rwxr-xr-xactiverecord/lib/active_record/connection_adapters/abstract_adapter.rb19
1 files changed, 15 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index 1137ea1011..1b5c8184ae 100755
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -357,9 +357,10 @@ module ActiveRecord
sql << " OFFSET #{options[:offset]}" if options.has_key?(:offset) and !options[:offset].nil?
end
+
def initialize_schema_information
begin
- execute "CREATE TABLE schema_info (version #{native_database_types[:integer][:name]}(#{native_database_types[:integer][:limit]}))"
+ execute "CREATE TABLE schema_info (version #{type_to_sql(:integer)})"
insert "INSERT INTO schema_info (version) VALUES(0)"
rescue ActiveRecord::StatementInvalid
# Schema has been intialized
@@ -378,8 +379,7 @@ module ActiveRecord
def add_column(table_name, column_name, type, options = {})
native_type = native_database_types[type]
- add_column_sql = "ALTER TABLE #{table_name} ADD #{column_name} #{native_type[:name]}"
- add_column_sql << "(#{options[:limit] || native_type[:limit]})" if options[:limit] || native_type[:limit]
+ add_column_sql = "ALTER TABLE #{table_name} ADD #{column_name} #{type_to_sql(type)}"
add_column_sql << " DEFAULT '#{options[:default]}'" if options[:default]
execute(add_column_sql)
end
@@ -387,9 +387,20 @@ module ActiveRecord
def remove_column(table_name, column_name)
execute "ALTER TABLE #{table_name} DROP #{column_name}"
end
+
+ def supports_migrations?
+ false
+ end
protected
+ def type_to_sql(type)
+ native = native_database_types[type]
+ column_type_sql = native[:name]
+ column_type_sql << "(#{native[:limit]})" if native[:limit]
+ column_type_sql
+ end
+
def log(sql, name)
begin
if block_given?
@@ -439,7 +450,7 @@ module ActiveRecord
"%s %s" % [message, dump]
end
end
- end
+ end
class TableDefinition
attr_accessor :columns