aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorFederico Martinez <fed.x.gibson@gmail.com>2018-05-31 00:49:25 -0300
committerFederico Martinez <fed.x.gibson@gmail.com>2018-06-01 18:58:51 -0300
commit7ef9849e3d51c1f4a37af368b770d8fdb41883cd (patch)
tree271fc8d3c1da3b8edc049ae9853773802066b8cf /activerecord/lib/active_record
parentc1844477a1461ffc9db3d899212f608c2a0c77c9 (diff)
downloadrails-7ef9849e3d51c1f4a37af368b770d8fdb41883cd.tar.gz
rails-7ef9849e3d51c1f4a37af368b770d8fdb41883cd.tar.bz2
rails-7ef9849e3d51c1f4a37af368b770d8fdb41883cd.zip
Migrations will raise an exception if there are multiple column definitions (same name).
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index 5f090d16cd..582ac516c7 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -356,8 +356,12 @@ module ActiveRecord
type = type.to_sym if type
options = options.dup
- if @columns_hash[name] && @columns_hash[name].primary_key?
- raise ArgumentError, "you can't redefine the primary key column '#{name}'. To define a custom primary key, pass { id: false } to create_table."
+ if @columns_hash[name]
+ if @columns_hash[name].primary_key?
+ raise ArgumentError, "you can't redefine the primary key column '#{name}'. To define a custom primary key, pass { id: false } to create_table."
+ else
+ raise ArgumentError, "you can't define an already defined column '#{name}'."
+ end
end
index_options = options.delete(:index)