masamune 0.17.11 → 0.17.12
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 +4 -4
- data/lib/masamune/tasks/dump_thor.rb +2 -0
- data/lib/masamune/transform/define_table.rb +1 -1
- data/lib/masamune/transform/postgres/define_table.rb +9 -3
- data/lib/masamune/version.rb +1 -1
- data/spec/masamune/tasks/dump_thor_spec.rb +10 -0
- data/spec/masamune/transform/define_table.table_spec.rb +28 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1eb266f52acc5ee8e0c52a49902c99818f6f12b5
|
4
|
+
data.tar.gz: d508a06edbd0ee12026452da4d6dcb8bc4d67602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
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
|
27
|
-
@files
|
28
|
-
@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
|
data/lib/masamune/version.rb
CHANGED
@@ -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
|
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.
|
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-
|
11
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|