Class: Ardb::CLI::GenerateMigrationCommand
- Inherits:
-
Object
- Object
- Ardb::CLI::GenerateMigrationCommand
- Includes:
- ValidCommand
- Defined in:
- lib/ardb/cli/commands.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.command_name ⇒ Object
144 |
# File 'lib/ardb/cli/commands.rb', line 144 def self.command_name; "generate-migration"; end |
.command_summary ⇒ Object
145 |
# File 'lib/ardb/cli/commands.rb', line 145 def self.command_summary; "Generate a MIGRATION-NAME migration file"; end |
Instance Method Details
#command_help ⇒ Object
169 170 171 172 173 174 |
# File 'lib/ardb/cli/commands.rb', line 169 def command_help "Usage: ardb #{self.command_name} MIGRATION-NAME [options]\n\n" \ "Options: #{self.clirb}\n" \ "Description:\n" \ " #{self.command_summary}" end |
#run(argv, *args) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/ardb/cli/commands.rb', line 147 def run(argv, *args) super begin Ardb.init(false) require "ardb/migration" migration = Ardb::Migration.new(Ardb.config, @clirb.args.first) migration.save! @stdout.puts "generated #{migration.file_path}" rescue Ardb::Migration::NoIdentifierError => exception error = ArgumentError.new("MIGRATION-NAME must be provided") error.set_backtrace(exception.backtrace) raise error rescue StandardError => e @stderr.puts e @stderr.puts e.backtrace.join("\n") @stderr.puts "error generating migration" raise CommandExitError end end |