diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 12 |
1 files changed, 7 insertions, 5 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 8f79cc17fe..ebf9a662c3 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -217,7 +217,12 @@ module ActiveRecord raise ArgumentError, "you can't redefine the primary key column '#{name}'. To define a custom primary key, pass { id: false } to create_table." end - column = self[name] || new_column_definition(name, type) + column = @columns_hash.fetch(name) { + col = new_column_definition(name, type) + @columns << col + @columns_hash[name] = col + col + } limit = options.fetch(:limit) do native[type][:limit] if native[type].is_a?(Hash) @@ -273,10 +278,7 @@ module ActiveRecord end def new_column_definition(name, type) - definition = create_column_definition name, type - @columns << definition - @columns_hash[name] = definition - definition + create_column_definition name, type end def primary_key_column_name |