masamune 0.17.11 → 0.17.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bedd64be2e2081da0dcd22d860eb4f502c83268f
4
- data.tar.gz: 8ebcbaa4c7c8011b7db7179ab1671e381d35edb4
3
+ metadata.gz: 1eb266f52acc5ee8e0c52a49902c99818f6f12b5
4
+ data.tar.gz: d508a06edbd0ee12026452da4d6dcb8bc4d67602
5
5
  SHA512:
6
- metadata.gz: a952af9940ed6d29d08623df5809b1100b813e3ac602fe4f206c88fc2cc52a9beaedfe4516b40a1ee20af9d665f32716a3e44e5b956a9c442380bdf583ca9e15
7
- data.tar.gz: cd3d3bebf7a7e09380244120fb25d20cb019c5544a21a52375e937810b052c1f57d5e34c882cb1e523b132d0f8bfae2183a315e24ed34b93cfd41b101c3aeedd
6
+ metadata.gz: 3e07e29a9d2ae2f8d30ca1e4955ff0a9be518f99ea6776aabc9ee5410dd79a3b4c99e28b2ce4cc0a772d4c0e7f693b18e6789567f5a8d7b201bf72b5ce9fe3dc
7
+ data.tar.gz: ae3fddf024a995705f361a0b11de610d1efe7f75e4211dbadcb604cd0ef410f6f5beb7821fdcb6cb3ee0ec3147d243cd8dea6e10485ff9b034646cdd7ef0972f
@@ -38,6 +38,7 @@ module Masamune::Tasks
38
38
  method_option :type, :enum => ['psql', 'hql'], :desc => 'Schema type', :default => 'psql'
39
39
  method_option :section, :enum => ['pre', 'post', 'all'], :desc => 'Schema section', :default => 'all'
40
40
  method_option :exclude, :type => :array, :desc => 'Exclude tables matching globs', :default => []
41
+ method_option :skip_indexes, :type => :boolean, :desc => 'Disable indexes', :default => false
41
42
  def dump_exec
42
43
  print_catalog
43
44
  exit
@@ -59,6 +60,7 @@ module Masamune::Tasks
59
60
  {
60
61
  exclude: options[:exclude],
61
62
  section: options[:section].to_sym,
63
+ skip_indexes: options[:skip_indexes],
62
64
  start_date: start_date,
63
65
  stop_date: stop_date
64
66
  }.reject { |_, v| v.blank? }
@@ -28,7 +28,7 @@ module Masamune::Transform
28
28
  return if target.implicit
29
29
  return if exclude_table?(target, options)
30
30
  child_tables = target.children.map { |child| define_table(child, options.except(:files)) }
31
- Operator.new(*child_tables, __method__, target: target, files: options[:files], section: options[:section]).tap do |operator|
31
+ Operator.new(*child_tables, __method__, target: target, **options).tap do |operator|
32
32
  logger.debug("#{target.id}\n" + operator.to_s) if target.debug
33
33
  end
34
34
  end
@@ -23,9 +23,10 @@
23
23
  module Masamune::Transform::Postgres
24
24
  class DefineTable
25
25
  def initialize(options = {})
26
- @target = options[:target]
27
- @files = options[:files] || []
28
- @section = options[:section]
26
+ @target = options[:target]
27
+ @files = options[:files] || []
28
+ @section = options[:section]
29
+ @skip_indexes = options[:skip_indexes]
29
30
  end
30
31
 
31
32
  def locals
@@ -44,6 +45,10 @@ module Masamune::Transform::Postgres
44
45
  @section || :all
45
46
  end
46
47
 
48
+ def skip_indexes?
49
+ !!@skip_indexes
50
+ end
51
+
47
52
  def define_types?
48
53
  !post_section?
49
54
  end
@@ -73,6 +78,7 @@ module Masamune::Transform::Postgres
73
78
 
74
79
  def define_indexes?
75
80
  return false if pre_section?
81
+ return false if skip_indexes?
76
82
  return true if post_section?
77
83
  !target.delay_indexes?
78
84
  end
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Masamune
24
- VERSION = '0.17.11'
24
+ VERSION = '0.17.12'
25
25
  end
@@ -67,6 +67,16 @@ describe Masamune::Tasks::DumpThor do
67
67
  it_behaves_like 'raises Thor::MalformattedArgumentError', %q{Expected '--section' to be one of pre, post, all; got unknown}
68
68
  end
69
69
 
70
+ context 'with --skip-indexes' do
71
+ let(:options) { ['--skip-indexes'] }
72
+ it_behaves_like 'executes with success'
73
+ end
74
+
75
+ context 'with --no-skip-indexes' do
76
+ let(:options) { ['--no-skip-indexes'] }
77
+ it_behaves_like 'executes with success'
78
+ end
79
+
70
80
  context %q{with --exclude='.*dimension'} do
71
81
  let(:options) { [%q{--exclude='.*dimension'}] }
72
82
  it_behaves_like 'executes with success'
@@ -25,7 +25,9 @@ describe Masamune::Transform::DefineTable do
25
25
  let(:section) { :all }
26
26
  let(:options) { { files: files, section: section } }
27
27
 
28
- subject { transform.define_table(target, options).to_s }
28
+ subject do
29
+ transform.define_table(target, options).to_s
30
+ end
29
31
 
30
32
  context 'for postgres table with columns' do
31
33
  before do
@@ -1011,4 +1013,29 @@ describe Masamune::Transform::DefineTable do
1011
1013
  EOS
1012
1014
  end
1013
1015
  end
1016
+
1017
+ context 'for postgres table with index columns and section :post and skip_indexes' do
1018
+ before do
1019
+ catalog.schema :postgres do
1020
+ table 'user' do
1021
+ column 'tenant_id', index: true
1022
+ column 'user_id', index: true
1023
+ end
1024
+ end
1025
+ end
1026
+
1027
+ let(:options) { { section: :post, skip_indexes: true } }
1028
+ let(:target) { catalog.postgres.user_table }
1029
+
1030
+ it 'should render table template' do
1031
+ is_expected.to eq <<-EOS.strip_heredoc
1032
+ DO $$ BEGIN
1033
+ IF NOT EXISTS (SELECT 1 FROM pg_class c WHERE c.relname = 'user_table_pkey') THEN
1034
+ ALTER TABLE user_table ADD PRIMARY KEY (id);
1035
+ END IF; END $$;
1036
+
1037
+ ANALYZE user_table;
1038
+ EOS
1039
+ end
1040
+ end
1014
1041
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: masamune
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.11
4
+ version: 0.17.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Andrews
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-06 00:00:00.000000000 Z
11
+ date: 2016-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor