dohmysql 0.2.12 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/migrate +13 -42
 - data/lib/doh/mysql/migrate/options.rb +41 -0
 - metadata +3 -2
 
    
        data/bin/migrate
    CHANGED
    
    | 
         @@ -2,58 +2,29 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'doh/app/cli'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'doh/mysql/migrate/runner'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'doh/mysql/migrate/analyzer'
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            [' 
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            [' 
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            ['merge', '<name>', 'UNIMPLEMENTED: executes the verify command, then git rm,commit'],
         
     | 
| 
       14 
     | 
    
         
            -
            ].freeze
         
     | 
| 
       15 
     | 
    
         
            -
            COMMANDS = COMMAND_INFO.collect {|name, args, desc| name}.freeze
         
     | 
| 
       16 
     | 
    
         
            -
            NOTIFY_COMMANDS = %w(apply revert)
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
            cmd_detail = COMMAND_INFO.collect do |name, args, desc|
         
     | 
| 
       19 
     | 
    
         
            -
              args = ' ' + args unless args.empty?
         
     | 
| 
       20 
     | 
    
         
            -
              name_rpad = ' ' * (33 - (name.size + args.size))
         
     | 
| 
       21 
     | 
    
         
            -
              "    #{name}#{args}#{name_rpad}#{desc}"
         
     | 
| 
       22 
     | 
    
         
            -
            end.join("\n")
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            opts = Doh::Options.new(
         
     | 
| 
       25 
     | 
    
         
            -
            {'database' => [Doh.config[:default_database], "-d", "--database <database>", "name of the database to migrate -- defaults to config[:default_database], currently '#{Doh.config[:default_database]}'"] \
         
     | 
| 
       26 
     | 
    
         
            -
            }, true, "Commands:\n\n#{cmd_detail}")
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            cmd_name = opts.varargs.shift
         
     | 
| 
       29 
     | 
    
         
            -
            cmd_args = opts.varargs
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
            unless COMMANDS.include?(cmd_name)
         
     | 
| 
       32 
     | 
    
         
            -
              warn "unrecognized command #{cmd_name}"
         
     | 
| 
       33 
     | 
    
         
            -
              exit 1
         
     | 
| 
       34 
     | 
    
         
            -
            end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
            if opts.database.to_s.empty?
         
     | 
| 
       37 
     | 
    
         
            -
              warn "You must specify a database, either here with -d or in config"
         
     | 
| 
       38 
     | 
    
         
            -
              exit 1
         
     | 
| 
       39 
     | 
    
         
            -
            end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
            if ['make', 'apply', 'revert'].include?(cmd_name)
         
     | 
| 
       42 
     | 
    
         
            -
              success, msg = DohDb::MigrateRunner.new(opts.database).send(cmd_name, *cmd_args)
         
     | 
| 
       43 
     | 
    
         
            -
            elsif ['check', 'verify'].include?(cmd_name)
         
     | 
| 
       44 
     | 
    
         
            -
              success, msg = DohDb::MigrateAnalyzer.new(opts.database).send(cmd_name, *cmd_args)
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'doh/mysql/migrate/options'
         
     | 
| 
      
 6 
     | 
    
         
            +
            module DohDb
         
     | 
| 
      
 7 
     | 
    
         
            +
            module Migrate
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            if ['make', 'apply', 'revert'].include?(CMD_NAME)
         
     | 
| 
      
 10 
     | 
    
         
            +
              success, msg = DohDb::MigrateRunner.new(OPTS.database).send(CMD_NAME, *CMD_ARGS)
         
     | 
| 
      
 11 
     | 
    
         
            +
            elsif ['check', 'verify'].include?(CMD_NAME)
         
     | 
| 
      
 12 
     | 
    
         
            +
              success, msg = DohDb::MigrateAnalyzer.new(OPTS.database).send(CMD_NAME, *CMD_ARGS)
         
     | 
| 
       45 
13 
     | 
    
         
             
            end
         
     | 
| 
       46 
14 
     | 
    
         | 
| 
       47 
15 
     | 
    
         
             
            if success
         
     | 
| 
       48 
16 
     | 
    
         
             
              puts "succcess: " + msg
         
     | 
| 
       49 
     | 
    
         
            -
              if NOTIFY_COMMANDS.include?( 
     | 
| 
      
 17 
     | 
    
         
            +
              if NOTIFY_COMMANDS.include?(CMD_NAME)
         
     | 
| 
       50 
18 
     | 
    
         
             
                dohlog.notify("success: #{msg}")
         
     | 
| 
       51 
19 
     | 
    
         
             
              end
         
     | 
| 
       52 
20 
     | 
    
         
             
            else
         
     | 
| 
       53 
21 
     | 
    
         
             
              warn "***************** FAILURE **********************"
         
     | 
| 
       54 
22 
     | 
    
         
             
              warn msg
         
     | 
| 
       55 
     | 
    
         
            -
              if NOTIFY_COMMANDS.include?( 
     | 
| 
      
 23 
     | 
    
         
            +
              if NOTIFY_COMMANDS.include?(CMD_NAME)
         
     | 
| 
       56 
24 
     | 
    
         
             
                dohlog.notify("FAILURE: #{msg}")
         
     | 
| 
       57 
25 
     | 
    
         
             
              end
         
     | 
| 
       58 
26 
     | 
    
         
             
              exit 1
         
     | 
| 
       59 
27 
     | 
    
         
             
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module DohDb
         
     | 
| 
      
 2 
     | 
    
         
            +
            module Migrate
         
     | 
| 
      
 3 
     | 
    
         
            +
            COMMAND_INFO = [
         
     | 
| 
      
 4 
     | 
    
         
            +
            ['make', '<name>', 'creates the files for a new migration'],
         
     | 
| 
      
 5 
     | 
    
         
            +
            ['check', '<name>', 'checks that all migrations are valid'],
         
     | 
| 
      
 6 
     | 
    
         
            +
            ['commit', '<name>', 'UNIMPLEMENTED: executes the check command, then git add,commit'],
         
     | 
| 
      
 7 
     | 
    
         
            +
            ['apply', '<name>', 'applies one or more migrations'],
         
     | 
| 
      
 8 
     | 
    
         
            +
            ['revert', '<name>', 'reverts one or more migrations'],
         
     | 
| 
      
 9 
     | 
    
         
            +
            ['verify' ,'<name>', 'verifies that the migration has been integrated into the base files'],
         
     | 
| 
      
 10 
     | 
    
         
            +
            ['merge', '<name>', 'UNIMPLEMENTED: executes the verify command, then git rm,commit'],
         
     | 
| 
      
 11 
     | 
    
         
            +
            ].freeze
         
     | 
| 
      
 12 
     | 
    
         
            +
            COMMANDS = COMMAND_INFO.collect {|name, args, desc| name}.freeze
         
     | 
| 
      
 13 
     | 
    
         
            +
            NOTIFY_COMMANDS = %w(apply revert)
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            cmd_detail = COMMAND_INFO.collect do |name, args, desc|
         
     | 
| 
      
 16 
     | 
    
         
            +
              args = ' ' + args unless args.empty?
         
     | 
| 
      
 17 
     | 
    
         
            +
              name_rpad = ' ' * (33 - (name.size + args.size))
         
     | 
| 
      
 18 
     | 
    
         
            +
              "    #{name}#{args}#{name_rpad}#{desc}"
         
     | 
| 
      
 19 
     | 
    
         
            +
            end.join("\n")
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            OPTS = Doh::Options.new(
         
     | 
| 
      
 22 
     | 
    
         
            +
            {'database' => [Doh.config[:default_database], "-d", "--database <database>", "name of the database to migrate -- defaults to config[:default_database], currently '#{Doh.config[:default_database]}'"] \
         
     | 
| 
      
 23 
     | 
    
         
            +
            }, true, "Commands:\n\n#{cmd_detail}")
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            CMD_NAME, CMD_ARGS = OPTS.varargs.shift, OPTS.varargs
         
     | 
| 
      
 26 
     | 
    
         
            +
            unless COMMANDS.include?(CMD_NAME)
         
     | 
| 
      
 27 
     | 
    
         
            +
              warn "unrecognized command #{cmd_name}"
         
     | 
| 
      
 28 
     | 
    
         
            +
              exit 1
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            if OPTS.database.to_s.empty?
         
     | 
| 
      
 32 
     | 
    
         
            +
              warn "You must specify a database, either here with -d or in config"
         
     | 
| 
      
 33 
     | 
    
         
            +
              exit 1
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            def self.cmd_name_and_args
         
     | 
| 
      
 37 
     | 
    
         
            +
              [OPTS, CMD_NAME, CMD_ARGS]
         
     | 
| 
      
 38 
     | 
    
         
            +
            end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: dohmysql
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.13
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2013-03- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2013-03-18 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: dohroot
         
     | 
| 
         @@ -118,6 +118,7 @@ files: 
     | 
|
| 
       118 
118 
     | 
    
         
             
            - lib/doh/mysql/load_sql.rb
         
     | 
| 
       119 
119 
     | 
    
         
             
            - lib/doh/mysql/metadata_util.rb
         
     | 
| 
       120 
120 
     | 
    
         
             
            - lib/doh/mysql/migrate/analyzer.rb
         
     | 
| 
      
 121 
     | 
    
         
            +
            - lib/doh/mysql/migrate/options.rb
         
     | 
| 
       121 
122 
     | 
    
         
             
            - lib/doh/mysql/migrate/runner.rb
         
     | 
| 
       122 
123 
     | 
    
         
             
            - lib/doh/mysql/raw_row_builder.rb
         
     | 
| 
       123 
124 
     | 
    
         
             
            - lib/doh/mysql/readonly_row.rb
         
     |