Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tooling/danger/database.rb')
-rw-r--r--tooling/danger/database.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/tooling/danger/database.rb b/tooling/danger/database.rb
new file mode 100644
index 00000000000..4cfac7c4af4
--- /dev/null
+++ b/tooling/danger/database.rb
@@ -0,0 +1,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