blob: 4cfac7c4af44a04a1475d97557881bc792934247 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# frozen_string_literal: true
module Tooling
module Danger
module Database
TIMESTAMP_MATCHER = /(?<timestamp>\d{14})/
MIGRATION_MATCHER = %r{\A(ee/)?db/(geo/)?(post_)?migrate/}
def find_migration_files_before(file_names, cutoff)
migrations = file_names.select { |f| f.match?(MIGRATION_MATCHER) }
migrations.select do |migration|
next unless match = TIMESTAMP_MATCHER.match(migration)
timestamp = Date.parse(match[:timestamp])
timestamp < cutoff
end
end
end
end
end
|