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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /scripts/validate_migration_timestamps
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'scripts/validate_migration_timestamps')
-rwxr-xr-xscripts/validate_migration_timestamps24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/validate_migration_timestamps b/scripts/validate_migration_timestamps
new file mode 100755
index 00000000000..d3722e7a4af
--- /dev/null
+++ b/scripts/validate_migration_timestamps
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+
+# frozen_string_literal: true
+
+require 'time'
+
+MIGRATION_DIRS = %w[db/migrate db/post_migrate].freeze
+VERSION_DIGITS = 14
+MIGRATION_TIMESTAMP_REGEX = /\A(?<version>\d{#{VERSION_DIGITS}})_/.freeze
+
+maximum_timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S').to_i
+
+MIGRATION_DIRS.each do |migration_dir|
+ Dir[File.join(migration_dir, '*.rb')].each do |filename|
+ file_basename = File.basename(filename)
+ version_match = MIGRATION_TIMESTAMP_REGEX.match(file_basename)
+
+ raise "#{filename} has an invalid migration version" if version_match.nil?
+
+ migration_timestamp = version_match['version'].to_i
+
+ raise "#{filename} has a future timestamp" if migration_timestamp > maximum_timestamp
+ end
+end