Class: Gitlab::Database::Sos::ArSchemaDump
- Inherits:
-
Object
- Object
- Gitlab::Database::Sos::ArSchemaDump
- Defined in:
- lib/gitlab/database/sos/ar_schema_dump.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(connection, name, output) ⇒ ArSchemaDump
constructor
A new instance of ArSchemaDump.
- #run ⇒ Object
Constructor Details
#initialize(connection, name, output) ⇒ ArSchemaDump
Returns a new instance of ArSchemaDump.
9 10 11 12 13 |
# File 'lib/gitlab/database/sos/ar_schema_dump.rb', line 9 def initialize(connection, name, output) @connection = connection @name = name @output = output end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
7 8 9 |
# File 'lib/gitlab/database/sos/ar_schema_dump.rb', line 7 def connection @connection end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/gitlab/database/sos/ar_schema_dump.rb', line 7 def name @name end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
7 8 9 |
# File 'lib/gitlab/database/sos/ar_schema_dump.rb', line 7 def output @output end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gitlab/database/sos/ar_schema_dump.rb', line 15 def run file_path = File.join(name, "#{name}_schema_dump.sql") output.write_file(file_path) do |f| File.open(f, 'w') do |file| connection.create_schema_dumper({}).dump(file) end end rescue StandardError => e Gitlab::AppLogger.error("Error writing schema dump for DB:#{name} with error message:#{e.}") end |