convergence 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c26bf3742a050cf1c1f19c5077900c5399eab4ed
4
- data.tar.gz: f956e136b15aa7da59b076876130397a5541f2a8
3
+ metadata.gz: a094b6afa402acbb8e29b69c60580f89322b8437
4
+ data.tar.gz: 39ad0cfc2bcefed5cb2fcc365d73484933fcb017
5
5
  SHA512:
6
- metadata.gz: 69b9bf97488d41d38c77653cf670cd1d8dd83462e275609fb4b08d808def10802e23f7bb12666229cde592faf127503c2cd88f136c990614ce4b2d860b69436a
7
- data.tar.gz: 760af609f15854528884f4861d44bad95a6c4e3038e82b489c69ebb081a5b9714a4615909180648019ed36325a7a5364b448ca54758cfc76137b2f92d49cd53f
6
+ metadata.gz: c6bd2505d21ab261de51ed9c08b38a09954333c192e919d21afa2c79abb2c444e6ef044ca23c33872b1a762c4bfa7cd814744f9de4c7d3ebf024f9fc50776696
7
+ data.tar.gz: 806d68d3b11c388ded5932d6f68e89520e4c70dfab1c90d5dc3f0590257e5abbfec6600461e016458aa2c4afd444d2d88e51465af5866c8e5893db19178b78a7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## Convergence 1.0.1 (September 27, 2018) ##
2
+
3
+ * Add Rollback Dryrun command (PR: #64)
4
+
5
+ *nishio-dens*
6
+
1
7
  ## Convergence 1.0.0 (August 28, 2018) ##
2
8
 
3
9
  * [BREAKING CHANGE] Change flag style command to sub-command style (PR: #60)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- convergence (1.0.0)
4
+ convergence (1.0.1)
5
5
  diff-lcs
6
6
  diffy
7
7
  mysql2
data/README.md CHANGED
@@ -196,6 +196,13 @@ end
196
196
  $ convergence apply example.schema -c database.yml --dry-run
197
197
  ```
198
198
 
199
+ ### Rollback Dry run
200
+
201
+ ```
202
+ $ convergence apply example.schema -c database.yml --rollback-dry-run
203
+ ```
204
+
205
+
199
206
  ### Apply
200
207
 
201
208
  ```
@@ -5,18 +5,22 @@ require 'convergence/module'
5
5
  require 'convergence/config'
6
6
 
7
7
  class Convergence::CLI < Thor
8
- default_command :__fallback # TODO: `__fallback` will be removed in a future version(maybe v0.4.0)
9
-
8
+ default_command :__fallback # TODO: `__fallback` will be removed in a future version(maybe v1.1.0)
9
+
10
10
  map %w[--version -v] => :version
11
11
 
12
12
  desc 'apply FILE', 'execute sql to your database'
13
13
  method_option :config, aliases: '-c', type: :string, required: true, desc: 'Database Yaml Setting'
14
14
  method_option :dry_run, type: :boolean
15
+ method_option :rollback_dry_run, type: :boolean
15
16
  def apply(file)
16
17
  opts = { input: file }
17
18
  if options[:dry_run]
18
19
  require 'convergence/command/dryrun'
19
20
  Convergence::Command::Dryrun.new(opts, config: config).execute
21
+ elsif options[:rollback_dry_run]
22
+ require 'convergence/command/rollback_dryrun'
23
+ Convergence::Command::RollbackDryrun.new(opts, config: config).execute
20
24
  else
21
25
  require 'convergence/command/apply'
22
26
  Convergence::Command::Apply.new(opts, config: config).execute
@@ -44,7 +48,7 @@ class Convergence::CLI < Thor
44
48
  puts "version #{Convergence::VERSION}"
45
49
  end
46
50
 
47
- # TODO: `__fallback` will be removed in a future version(maybe v0.4.0)
51
+ # TODO: `__fallback` will be removed in a future version(maybe v1.1.0)
48
52
  desc '', '', hide: true
49
53
  method_option :config,
50
54
  aliases: '-c', type: :string,
@@ -99,6 +103,6 @@ class Convergence::CLI < Thor
99
103
  end
100
104
 
101
105
  def deprecation_warning
102
- warn '[DEPRECATION] Option style is deprecated. Please use subscommand style.'
106
+ warn '[DEPRECATION] Flag style command is deprecated. Please use sub-command style instead.'
103
107
  end
104
108
  end
@@ -41,7 +41,7 @@ class Convergence::Command::Dryrun < Convergence::Command
41
41
  .split("\n")
42
42
  .map { |v| '# ' + v }
43
43
  .join("\n")
44
- logger.output(msg)
44
+ logger.output(msg) unless msg.empty?
45
45
  msg
46
46
  end
47
47
  end
@@ -0,0 +1,32 @@
1
+ require 'pathname'
2
+ require 'convergence/command'
3
+ require 'convergence/command/apply'
4
+ require 'convergence/dsl'
5
+ require 'convergence/default_parameter'
6
+
7
+ class Convergence::Command::RollbackDryrun < Convergence::Command
8
+ def validate!
9
+ fail ArgumentError.new('config required') if @config.nil?
10
+ fail ArgumentError.new('input required') unless @opts[:input]
11
+ end
12
+
13
+ def execute
14
+ validate!
15
+ current_dir_path = Pathname.new(@opts[:input]).realpath.dirname
16
+ input_tables = Convergence::DSL.parse(File.open(@opts[:input]).read, current_dir_path)
17
+ current_tables = dumper.dump
18
+
19
+ output_sql(current_tables, input_tables)
20
+ end
21
+
22
+ def output_sql(input_tables, current_tables)
23
+ msg = Convergence::Command::Apply
24
+ .new(@opts, config: @config)
25
+ .generate_sql(input_tables, current_tables)
26
+ .split("\n")
27
+ .map { |v| '# ' + v }
28
+ .join("\n")
29
+ logger.output(msg)
30
+ msg
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Convergence
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convergence
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinsuke Nishio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-28 00:00:00.000000000 Z
11
+ date: 2018-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2
@@ -194,6 +194,7 @@ files:
194
194
  - lib/convergence/command/diff.rb
195
195
  - lib/convergence/command/dryrun.rb
196
196
  - lib/convergence/command/export.rb
197
+ - lib/convergence/command/rollback_dryrun.rb
197
198
  - lib/convergence/config.rb
198
199
  - lib/convergence/database_connector.rb
199
200
  - lib/convergence/database_connector/mysql_connector.rb