master_data_tool 0.12.0 → 0.15.0

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
  SHA256:
3
- metadata.gz: 69795950505c4ab8feeb32605e77d588da3922793d21e2eeb59995c6a3ac2238
4
- data.tar.gz: dd153019b32a9808bc5c8da0f6dba8add7ffcb753f85940882efce22a2aac3b5
3
+ metadata.gz: d9ee8634a9d307fdaa7f6cae268d9955a029309dbd020755ecac87ba0f8f6c4a
4
+ data.tar.gz: 31c3397ccc5d219fe933b7a0aa856878578fa061c4ab620d4e1dab39312d446c
5
5
  SHA512:
6
- metadata.gz: 2107f256a35f5a8ad8e9a9cfb8f6b668e9518b185eeb91a42b4aac7b56695841abf1f627a1c182e0afc6f06a441c2b5569c5f9e62985d76f76d89f30c5a37d2d
7
- data.tar.gz: 587736de3714b372e702e9338a6dfa6e45c44251fcf584b1d0c117a7bca8120cb12a9c97a9635ccaad34e0dd6693e5149253ac20a7201802f9b84f572bc474bd
6
+ metadata.gz: 8409b81d4129b18b0fa489ca0fbaf8a73f5fac79726ee4fed5745bf9312ac24958c6908735fc7a0fc453184e17609348b68e741939b98105547a4de6e1e02315
7
+ data.tar.gz: f1648f8c1123911468988ea553c1fbe5ad38b81893c5bd376c5f29f983d325672ce8c762020e8f91c7b83cca7d30f3da71919d69e24c11b728cdac7ce044a827
data/README.md CHANGED
@@ -68,12 +68,13 @@ bundle exec thor master_data_tool import \
68
68
 
69
69
  ### ダンプ
70
70
 
71
- | option | default | 内容 |
72
- |-----------------------|---------|---------------|
73
- | --ignore-empty-table | true | 空のテーブルを無視する |
74
- | --ignore-tables | [] | 指定したテーブルを無視する |
75
- | --ignore-column-names | [] | 指定したカラムを無視する |
76
- | --verbose | false | 詳細表示 |
71
+ | option | default | 内容 |
72
+ |-----------------------|---------|-----------------|
73
+ | --ignore-empty-table | true | 空のテーブルを無視する |
74
+ | --ignore-tables | [] | 指定したテーブルを無視する |
75
+ | --ignore-column-names | [] | 指定したカラムを無視する |
76
+ | --only-tables | nil | 指定したテーブルのみダンプする |
77
+ | --verbose | false | 詳細表示 |
77
78
 
78
79
  ```bash
79
80
  bundle exec master_data_tool dump
@@ -86,6 +87,7 @@ bundle exec master_data_tool dump \
86
87
  --ignore-empty-table=true \
87
88
  --ignore-tables="" \
88
89
  --ignore-column-names="" \
90
+ --only-tables="" \
89
91
  --verbose=false
90
92
  ```
91
93
 
data/docker-compose.yml CHANGED
@@ -4,12 +4,18 @@ x-mysql: &mysql
4
4
  image: mysql:5.7
5
5
  container_name: master_data_tool_mysql57
6
6
  environment:
7
- MYSQL_ROOT_PASSWORD: 'f3WpxNreVT2NgQry'
7
+ MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-f3WpxNreVT2NgQry}
8
8
  platform: linux/x86_64
9
9
  ports:
10
- - 127.0.0.1::3306
10
+ - 127.0.0.1:${DB_PORT:-33306}:3306
11
11
  volumes:
12
12
  - mysql:/var/lib/mysql
13
+ command: >
14
+ mysqld
15
+ --sql-mode=NO_ENGINE_SUBSTITUTION
16
+ --character-set-server=utf8mb4
17
+ --innodb-file-per-table=1
18
+ --innodb-large-prefix
13
19
 
14
20
  services:
15
21
  mysql:
data/exe/master_data_tool CHANGED
@@ -28,18 +28,21 @@ module MasterDataTool
28
28
  option :ignore_empty_table, default: true, type: :boolean
29
29
  option :ignore_tables, default: [], type: :array
30
30
  option :ignore_column_names, default: [], type: :array
31
+ option :only_tables, default: nil, type: :array
31
32
  option :verbose, default: false, type: :boolean
32
33
  desc 'dump', 'dump'
33
34
  def dump
34
35
  ignore_empty_table = options[:ignore_empty_table]
35
36
  ignore_tables = options[:ignore_tables]
36
37
  ignore_column_names = options[:ignore_column_names]
38
+ only_tables = options[:only_tables]
37
39
  verbose = options[:verbose]
38
40
 
39
41
  executor = MasterDataTool::Dump::Executor.new(
40
42
  ignore_empty_table: ignore_empty_table,
41
43
  ignore_tables: ignore_tables,
42
44
  ignore_column_names: ignore_column_names,
45
+ only_tables: only_tables,
43
46
  verbose: verbose
44
47
  )
45
48
  errors = executor.execute
@@ -8,10 +8,11 @@ module MasterDataTool
8
8
  DEFAULT_IGNORE_TABLES = %w[ar_internal_metadata schema_migrations master_data_statuses]
9
9
  DEFAULT_IGNORE_COLUMNS = %w[created_at updated_at]
10
10
 
11
- def initialize(ignore_empty_table: true, ignore_tables: [], ignore_column_names: [], verbose: false)
11
+ def initialize(ignore_empty_table: true, ignore_tables: [], ignore_column_names: [], only_tables: [], verbose: false)
12
12
  @ignore_empty_table = ignore_empty_table
13
13
  @ignore_tables = DEFAULT_IGNORE_TABLES + Array(MasterDataTool.config.dump_ignore_tables) + ignore_tables
14
14
  @ignore_column_names = DEFAULT_IGNORE_COLUMNS + Array(MasterDataTool.config.dump_ignore_columns) + ignore_column_names
15
+ @only_tables = Array(only_tables)
15
16
  end
16
17
 
17
18
  def execute
@@ -23,6 +24,11 @@ module MasterDataTool
23
24
  next
24
25
  end
25
26
 
27
+ if @only_tables.any? && !@only_tables.include?(table)
28
+ print_message "[skip] #{table}"
29
+ next
30
+ end
31
+
26
32
  dump_to_csv(table)
27
33
  rescue => e
28
34
  errors << Error.new(table, e)
@@ -50,6 +50,8 @@ module MasterDataTool
50
50
  private
51
51
 
52
52
  def print_execute_options
53
+ return if @silent
54
+
53
55
  puts "==== execute ===="
54
56
  instance_variables.each do |k|
55
57
  puts "#{k}: #{instance_variable_get(k)}"
@@ -6,6 +6,8 @@ module MasterDataTool
6
6
  include Printer
7
7
 
8
8
  def print(message)
9
+ return if @silent
10
+
9
11
  MasterDataTool.config.logger.info message
10
12
  puts message
11
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MasterDataTool
4
- VERSION = "0.12.0"
4
+ VERSION = "0.15.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: master_data_tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Ooishi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-24 00:00:00.000000000 Z
11
+ date: 2022-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec