2016-06-24 11:26:28 -04:00
|
|
|
module RuboCop
|
|
|
|
# Module containing helper methods for writing migration cops.
|
|
|
|
module MigrationHelpers
|
|
|
|
# Returns true if the given node originated from the db/migrate directory.
|
|
|
|
def in_migration?(node)
|
2017-05-22 12:31:22 -04:00
|
|
|
dirname = File.dirname(node.location.expression.source_buffer.name)
|
|
|
|
|
|
|
|
dirname.end_with?('db/migrate', 'db/post_migrate')
|
2016-06-24 11:26:28 -04:00
|
|
|
end
|
2017-12-11 11:34:51 -05:00
|
|
|
|
|
|
|
def in_post_deployment_migration?(node)
|
|
|
|
dirname = File.dirname(node.location.expression.source_buffer.name)
|
|
|
|
|
|
|
|
dirname.end_with?('db/post_migrate')
|
|
|
|
end
|
2016-06-24 11:26:28 -04:00
|
|
|
end
|
|
|
|
end
|