summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/database.rb4
-rw-r--r--lib/tasks/gitlab/db.rake4
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index e4d4779ba9a..5e5b79b8e99 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -11,6 +11,10 @@ module Gitlab
# https://dev.mysql.com/doc/refman/5.7/en/datetime.html
MAX_TIMESTAMP_VALUE = Time.at((1 << 31) - 1).freeze
+ # Minimum schema version from which migrations are be supported
+ # Migrations before this version may have been removed
+ MIN_SCHEMA_VERSION = 20190506135400
+
def self.config
ActiveRecord::Base.configurations[Rails.env]
end
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index 4e7a8adbef6..3a371de5bb7 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -53,6 +53,10 @@ namespace :gitlab do
# Check if we have existing db tables
# The schema_migrations table will still exist if drop_tables was called
if ActiveRecord::Base.connection.tables.count > 1
+ if ActiveRecord::Migrator.current_version < Gitlab::Database::MIN_SCHEMA_VERSION
+ raise "Your current database version is too old to be migrated. Please see https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations"
+ end
+
Rake::Task['db:migrate'].invoke
else
# Add post-migrate paths to ensure we mark all migrations as up