diff options
Diffstat (limited to 'lib/tasks/gitlab/db.rake')
-rw-r--r-- | lib/tasks/gitlab/db.rake | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index 72fe190bc8f..963fe23c682 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -109,9 +109,11 @@ namespace :gitlab do load_database = connection.tables.count <= 1 if load_database + puts "Running db:schema:load#{database_name} rake task" Gitlab::Database.add_post_migrate_path_to_rails(force: true) Rake::Task["db:schema:load#{database_name}"].invoke else + puts "Running db:migrate#{database_name} rake task" Rake::Task["db:migrate#{database_name}"].invoke end @@ -444,6 +446,31 @@ namespace :gitlab do end end + namespace :schema_checker do + desc 'Checks schema inconsistencies' + task run: :environment do + database_model = Gitlab::Database.database_base_models[Gitlab::Database::MAIN_DATABASE_NAME] + database = Gitlab::Database::SchemaValidation::Database.new(database_model.connection) + + stucture_sql_path = Rails.root.join('db/structure.sql') + structure_sql = Gitlab::Database::SchemaValidation::StructureSql.new(stucture_sql_path) + + inconsistencies = Gitlab::Database::SchemaValidation::Runner.new(structure_sql, database).execute + + gitlab_url = 'gitlab-org/gitlab' + + inconsistencies.each do |inconsistency| + Gitlab::Database::SchemaValidation::TrackInconsistency.new( + inconsistency, + Project.find_by_full_path(gitlab_url), + User.support_bot + ).execute + + puts inconsistency.inspect + end + end + end + namespace :dictionary do DB_DOCS_PATH = File.join(Rails.root, 'db', 'docs') EE_DICTIONARY_PATH = File.join(Rails.root, 'ee', 'db', 'docs') |