Skip to content

db:migrate:redo reverses the annotation but doesn't redo it #548

Closed
@zoras

Description

@zoras

As you can see below db:migrate:redo task rolls back the annotation but doesn't redo it, so the intended annotation isn't there at the end.

~/repo ❯ bundle pristine annotate
Installing annotate 2.7.2

~/repo ❯ rails -v
Rails 5.1.5

~/repo ❯ rails db:migrate
== 20180323104420 AddLockableToUsers: migrating ===============================
-- add_column(:users, :failed_attempts, :integer, {:default=>0, :comment=>"Only if lock strategy is :failed_attempts"})
   -> 0.0452s
-- add_column(:users, :unlock_token, :string, {:comment=>"Only if unlock strategy is :email or :both"})
   -> 0.0036s
-- add_column(:users, :locked_at, :datetime, {:comment=>"Lockable"})
   -> 0.0033s
== 20180323104420 AddLockableToUsers: migrated (0.0524s) ======================

Annotated (2): app/models/user.rb, spec/factories/users.rb

~/repo ❯ git commit -m 'Add locable to devise'

~/repo ❯ rails db:migrate:redo
== 20180323104420 AddLockableToUsers: reverting ===============================
-- remove_column(:users, :locked_at, :datetime, {:comment=>"Lockable"})
   -> 0.0037s
-- remove_column(:users, :unlock_token, :string, {:comment=>"Only if unlock strategy is :email or :both"})
   -> 0.0013s
-- remove_column(:users, :failed_attempts, :integer, {:default=>0, :comment=>"Only if lock strategy is :failed_attempts"})
   -> 0.0014s
== 20180323104420 AddLockableToUsers: reverted (0.0173s) ======================

Annotated (2): app/models/user.rb, spec/factories/users.rb
== 20180323104420 AddLockableToUsers: migrating ===============================
-- add_column(:users, :failed_attempts, :integer, {:default=>0, :comment=>"Only if lock strategy is :failed_attempts"})
   -> 0.2962s
-- add_column(:users, :unlock_token, :string, {:comment=>"Only if unlock strategy is :email or :both"})
   -> 0.0028s
-- add_column(:users, :locked_at, :datetime, {:comment=>"Lockable"})
   -> 0.0027s
== 20180323104420 AddLockableToUsers: migrated (0.3020s) ======================

~/repo ❯ git diff app/models/user.rb
-#  failed_attempts        :integer          default(0)            # Only if lock strategy is :failed_attempts
-#  unlock_token           :string                                 # Only if unlock strategy is :email or :both
-#  locked_at              :datetime                               # Lockable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions