diff options
| author | Jamis Buck <jamis@37signals.com> | 2005-09-24 00:33:47 +0000 | 
|---|---|---|
| committer | Jamis Buck <jamis@37signals.com> | 2005-09-24 00:33:47 +0000 | 
| commit | 1f4dc25250d828dd7f4c2c1c8e1d23c24c3e8d0b (patch) | |
| tree | 9d8909943432ab201f6887949e8c8db82e855155 | |
| parent | 11411effded1e3b2c6cf4577be22e75ac4dd48b3 (diff) | |
| download | rails-1f4dc25250d828dd7f4c2c1c8e1d23c24c3e8d0b.tar.gz rails-1f4dc25250d828dd7f4c2c1c8e1d23c24c3e8d0b.tar.bz2 rails-1f4dc25250d828dd7f4c2c1c8e1d23c24c3e8d0b.zip | |
Make the sqlite adapter preserve not-null constraints and index names when altering tables
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2318 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
| -rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb | 15 | 
1 files changed, 12 insertions, 3 deletions
| diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 7d2d8986a1..e426149e02 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -261,7 +261,8 @@ module ActiveRecord                  options[:rename][column.name] if options[:rename]                @definition.column(column_name || column.name, column.type,  -                :limit => column.limit, :default => column.default) +                :limit => column.limit, :default => column.default, +                :null => column.null)              end              @definition.primary_key(primary_key(from))              yield @definition if block_given? @@ -275,8 +276,16 @@ module ActiveRecord          def copy_table_indexes(from, to) #:nodoc:            indexes(from).each do |index| -            type = index[:unique] ? 'UNIQUE' : '' -            add_index(to, index[:columns], type) +            name = index.name +            if to == "altered_#{from}" +              name = "temp_#{name}" +            elsif from == "altered_#{to}" +              name = name[5..-1] +            end + +            opts = { :name => name } +            opts[:unique] = true if index.unique +            add_index(to, index.columns, opts)            end          end | 
