Sha256: 863af93a1e9b96d71e50a616d2893b0fd8241024fc3bb38d1234b18dbd3b14c6
Contents?: true
Size: 1.77 KB
Versions: 3
Compression:
Stored size: 1.77 KB
Contents
# frozen_string_literal: true module Hanami module CLI module Commands module App module DB # @api private module Structure # @api private class Dump < DB::Command desc "Dumps database structure to config/db/structure.sql file" option :gateway, required: false, desc: "Use database for gateway" # @api private def call(app: false, slice: nil, gateway: nil, command_exit: method(:exit), **) exit_codes = [] databases(app: app, slice: slice, gateway: gateway).each do |database| relative_structure_path = database.structure_file .relative_path_from(database.slice.app.root) measure("#{database.name} structure dumped to #{relative_structure_path}") do catch :dump_failed do result = database.exec_dump_command exit_codes << result.exit_code if result.respond_to?(:exit_code) unless result.successful? out.puts result.err throw :dump_failed, false end migrations_sql = database.schema_migrations_sql_dump if migrations_sql File.open(database.structure_file, "a") do |f| f.puts "#{migrations_sql}\n" end end true end end end exit_codes.each do |code| break command_exit.(code) if code > 0 end end end end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems