debian-mirror-gitlab/lib/gitlab/database/schema_cleaner.rb
2020-06-23 00:09:42 +05:30

31 lines
680 B
Ruby

# frozen_string_literal: true
module Gitlab
module Database
class SchemaCleaner
attr_reader :original_schema
def initialize(original_schema)
@original_schema = original_schema
end
def clean(io)
structure = original_schema.dup
# Remove noise
structure.gsub!(/^COMMENT ON EXTENSION.*/, '')
structure.gsub!(/^SET.+/, '')
structure.gsub!(/^SELECT pg_catalog\.set_config\('search_path'.+/, '')
structure.gsub!(/^--.*/, "\n")
structure = "SET search_path=public;\n" + structure
structure.gsub!(/\n{3,}/, "\n\n")
io << structure
nil
end
end
end
end