Skip to content

Commit 528c0df

Browse files
committed
Annotate should reset the cached information about columns
Annotate should reset the cached information about columns because Annotate may output old information if we load ActiveRecord::Base class in migration files. For example, if we have a following migration file and execute 'rake db:migrate', Annote does not output the default value and a not null constraint of the `some_value` column. ```ruby class CreatePosts < ActiveRecord::Migration def change create_table :posts do |t| t.integer :some_value end # add a not null constraint to the some_value column # should update some_value with not null values # because records might exist which have null value in the some_value column Post.update_all(some_value: 1) change_column_null(:posts, :some_value, false) change_column_default(:posts, :some_value, 1) end end ``` This commit fixes the above issue.
1 parent 2bea946 commit 528c0df

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/annotate/annotate_models.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ def remove_annotation_of_file(file_name)
347347
#
348348
def annotate(klass, file, header, options={})
349349
begin
350+
klass.reset_column_information
350351
info = get_schema_info(klass, header, options)
351352
did_annotate = false
352353
model_name = klass.name.underscore

0 commit comments

Comments
 (0)