Sha256: 8f127c18cc5404d3db8b97af1e32acbec523e1d6b1ce1bbfca3e3eb8f54782cd

Contents?: true

Size: 1.94 KB

Versions: 2

Compression:

Stored size: 1.94 KB

Contents

# frozen_string_literal: true
#
# ronin-db - A common database library for managing and querying security data.
#
# Copyright (c) 2006-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# ronin-db is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ronin-db is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ronin-db.  If not, see <https://www.gnu.org/licenses/>.
#

require 'ronin/db/cli/database_command'
require 'ronin/db'

module Ronin
  module DB
    class CLI
      module Commands
        #
        # Runs database migrations.
        #
        # ## Usage
        #
        #     ronin-db migrate [options]
        #
        # ## Options
        #
        #         --db NAME                    The database to connect to (Default: default)
        #         --db-uri URI                 The database URI to connect to
        #     -h, --help                       Print help information
        # 
        class Migrate < DatabaseCommand

          usage '[options]'

          description 'Runs database migrations'

          man_page 'ronin-db-migrate.1'

          #
          # Runs the `ronin-db migrate` command.
          #
          def run
            connect
            migrate
          end

          #
          # Connects to the database.
          #
          def connect
            DB.connect(config, load_models: false)
          end

          #
          # Runs migrations.
          #
          def migrate
            DB.migrate!
          end

        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-db-0.1.0.beta1-java lib/ronin/db/cli/commands/migrate.rb
ronin-db-0.1.0.beta1 lib/ronin/db/cli/commands/migrate.rb