arxutils_sqlite3 0.1.47 → 0.1.48
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/arxutils_sqlite3.gemspec +4 -4
- data/exe/arxutils_sqlite3 +12 -51
- data/lib/arxutils_sqlite3/arx.rb +1 -0
- data/lib/arxutils_sqlite3/cli.rb +67 -0
- data/lib/arxutils_sqlite3/dbutil/dbrelation.rb +26 -0
- data/lib/arxutils_sqlite3/version.rb +1 -1
- data/lib/arxutils_sqlite3.rb +1 -0
- metadata +17 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68d6c8715c3a6aa14cd2d32e85d6757831555b23b5b1241417b01bf6d2527e91
|
4
|
+
data.tar.gz: 97612549672e709093582b1ccc1145cf4f5390c8fb9c17101f7c3e8e4e060db2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b0adfce62098bfe191391da978f3a3e7387201bc3161a46359165f694744a70730ff8b92b4b9ee8748ee46b7ecabc2b81e88718b15fae29ed0ed0db7638a745
|
7
|
+
data.tar.gz: 22b7ffc62b39e1b7b227f8298ee1d1da3ed72cbc52358364657a27578cbfd50cc6f0bdbd8393931405f4574d7d1667c15ca79f24ab6fccf522531f335f504361
|
data/arxutils_sqlite3.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_runtime_dependency "activesupport"
|
37
37
|
# spec.add_runtime_dependency "erb"
|
38
38
|
# spec.add_runtime_dependency "activerecord", "~> 4.2"
|
39
|
+
|
39
40
|
spec.add_runtime_dependency "activerecord", "~> 6.1"
|
40
41
|
spec.add_runtime_dependency "sqlite3"
|
41
42
|
spec.add_runtime_dependency "ykutils"
|
@@ -43,10 +44,9 @@ Gem::Specification.new do |spec|
|
|
43
44
|
spec.add_runtime_dependency "simpleoptparse"
|
44
45
|
# spec.add_development_dependency "bundler", "~> 2.2.10"
|
45
46
|
spec.add_development_dependency "bundler"
|
46
|
-
spec.add_development_dependency "
|
47
|
-
|
48
|
-
spec.add_development_dependency "
|
49
|
-
spec.add_development_dependency "rubocop"
|
47
|
+
spec.add_development_dependency "rspec" , "~> 3.0"
|
48
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
49
|
+
spec.add_development_dependency "rubocop", "~> 1.7"
|
50
50
|
spec.add_development_dependency "rubocop-rake"
|
51
51
|
spec.add_development_dependency "rubocop-rspec"
|
52
52
|
spec.add_development_dependency "yard"
|
data/exe/arxutils_sqlite3
CHANGED
@@ -8,6 +8,8 @@ require "ykxutils"
|
|
8
8
|
|
9
9
|
config = Arxutils_Sqlite3::Config.new
|
10
10
|
|
11
|
+
cli = Arxutils_Sqlite3::Cli.new(config)
|
12
|
+
|
11
13
|
config.require_opts_file
|
12
14
|
|
13
15
|
begin
|
@@ -34,6 +36,7 @@ Simpleoptparse::Simpleoptparse.parse(ARGV, opts, banner, Arxutils_Sqlite3::VERSI
|
|
34
36
|
parser.on("-y yaml_file", "--yaml yaml_file") { |x| opts["yaml"] = x }
|
35
37
|
parser.on("--klass klass") { |x| opts["klass"] = x }
|
36
38
|
end
|
39
|
+
klass = opts["klass"] if opts["klass"]
|
37
40
|
|
38
41
|
env = ENV.fetch("ENV", nil)
|
39
42
|
env ||= "production"
|
@@ -46,21 +49,12 @@ when "s"
|
|
46
49
|
puts banner
|
47
50
|
exit 20
|
48
51
|
end
|
49
|
-
klass
|
50
|
-
config.make_config_directory
|
51
|
-
config.setup_db_scheme_file
|
52
|
-
config.setup_opts_file(klass)
|
53
|
-
config.setup_setting_yaml_file(klass)
|
54
|
-
db_scheme_ary = nil
|
52
|
+
cli.setup(klass)
|
55
53
|
|
56
54
|
when "c"
|
57
|
-
db_scheme_ary = nil
|
58
55
|
dbconfig = opts["dbconfig"]
|
59
|
-
|
60
|
-
|
61
|
-
config.check_file_exist(dbconfig_path, banner, 30)
|
62
|
-
mig = config.prepare_for_migrate(db_scheme_ary, dbconfig_path, dbconfig, replation)
|
63
|
-
mig.make_dbconfig(opts)
|
56
|
+
relation = opts["relation"]
|
57
|
+
cli.makeconfig(dbconfig, relation, banner, 30, opts)
|
64
58
|
|
65
59
|
when "m"
|
66
60
|
yaml_fname = opts["yaml"]
|
@@ -72,57 +66,24 @@ when "m"
|
|
72
66
|
end
|
73
67
|
yaml_pn = Pathname.new(yaml_fname)
|
74
68
|
config.check_file_not_exist(yaml_pn, banner, 55)
|
75
|
-
db_scheme_ary = YAML.load_file( yaml_pn )
|
76
|
-
|
77
|
-
dest_dbsetup_file = config.get_dest_dbsetup_file
|
78
|
-
config.make_dbsetup_file(db_scheme_ary, relation, klass, dest_dbsetup_file)
|
79
69
|
|
80
|
-
|
81
|
-
|
82
|
-
# マイグレーション用スクリプトの生成、relationのクラス定義ファイルの生成
|
83
|
-
mig = config.prepare_for_migrate(db_scheme_ary, dbconfig_path, dbconfig, relation)
|
84
|
-
mig.output
|
85
|
-
|
86
|
-
# マイグレーション実行
|
87
|
-
ActiveRecord::MigrationContext.new(mig.migrate_dir, ActiveRecord::SchemaMigration).up
|
70
|
+
cli.migrate(yaml_pn, relation, klass, dbconfig, env)
|
88
71
|
|
89
72
|
when "i"
|
90
73
|
dbconfig = opts["dbconfig"]
|
91
|
-
|
92
|
-
Dbsetup.new(connect_time)
|
74
|
+
cli.integrate(dbconfig, env)
|
93
75
|
|
94
76
|
when "d"
|
95
77
|
db_scheme_ary = nil
|
96
78
|
dbconfig = opts["dbconfig"]
|
97
|
-
|
98
|
-
|
99
|
-
config_dir = config.get_config_dir
|
100
|
-
dbconfig_path = Arxutils_Sqlite3::Util.make_dbconfig_path(config_dir, dbconfig)
|
101
|
-
mig = config.prepare_for_migrate(db_scheme_ary, dbconfig_path, dbconfig, replation)
|
102
|
-
mig.delete_migrate_and_config_and_db
|
103
|
-
|
104
|
-
when "b"
|
105
|
-
db_scheme_ary = nil
|
106
|
-
dbconfig = opts["dbconfig"]
|
107
|
-
replation = opts["replation"]
|
108
|
-
|
109
|
-
config_dir = config.get_config_dir
|
110
|
-
dbconfig_path = Arxutils_Sqlite3::Util.make_dbconfig_path(config_dir, dbconfig)
|
111
|
-
mig = config.prepare_for_migrate(db_scheme_ary, dbconfig_path, dbconfig, replation)
|
112
|
-
# mig.delete_migrate_config_and_db
|
113
|
-
mig.delete_db
|
79
|
+
relation = opts["relation"]
|
80
|
+
cli.delete(dbconfig, db_scheme_ary, relation)
|
114
81
|
|
115
82
|
when "b"
|
116
83
|
db_scheme_ary = nil
|
117
84
|
dbconfig = opts["dbconfig"]
|
118
|
-
|
119
|
-
|
120
|
-
config_dir = config.get_config_dir
|
121
|
-
dbconfig_path = Arxutils_Sqlite3::Util.make_dbconfig_path(config_dir, dbconfig)
|
122
|
-
mig = config.prepare_for_migrate(db_scheme_ary, dbconfig_path, dbconfig, replation)
|
123
|
-
# mig.delete_migrate_config_and_db
|
124
|
-
mig.delete_db
|
125
|
-
|
85
|
+
relation = opts["relation"]
|
86
|
+
cli.delete_db(dbconfig, db_scheme_ary, relation)
|
126
87
|
else
|
127
88
|
puts "Invalid command(#{opts["cmd"]}) specified!!"
|
128
89
|
end
|
data/lib/arxutils_sqlite3/arx.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
module Arxutils_Sqlite3
|
2
|
+
# CLI用クラス
|
3
|
+
class Cli
|
4
|
+
def initialize(config)
|
5
|
+
@config = config
|
6
|
+
end
|
7
|
+
|
8
|
+
def setup(klass)
|
9
|
+
@config.make_config_directory
|
10
|
+
@config.setup_db_scheme_file
|
11
|
+
@config.setup_opts_file(klass)
|
12
|
+
@config.setup_setting_yaml_file(klass)
|
13
|
+
#db_scheme_ary = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def makeconfig(dbconfig, relation, banner, exit_code, opts)
|
17
|
+
db_scheme_ary = nil
|
18
|
+
dbconfig_path = @config.make_dbconfig_path(dbconfig)
|
19
|
+
@config.check_file_exist(dbconfig_path, banner, exit_code)
|
20
|
+
mig = @config.prepare_for_migrate(db_scheme_ary, dbconfig_path, dbconfig, relation)
|
21
|
+
mig.make_dbconfig(opts)
|
22
|
+
end
|
23
|
+
|
24
|
+
def migrate(yaml_pn, relation, klass, dbconfig, env)
|
25
|
+
db_scheme_ary = YAML.load_file( yaml_pn )
|
26
|
+
dbconfig_path = @config.make_dbconfig_path(dbconfig)
|
27
|
+
|
28
|
+
dest_dbsetup_file = @config.get_dest_dbsetup_file
|
29
|
+
@config.make_dbsetup_file(db_scheme_ary, relation, klass, dest_dbsetup_file)
|
30
|
+
|
31
|
+
connect_time = Arxutils_Sqlite3::Dbutil::Dbconnect.db_connect(@config, dbconfig, env)
|
32
|
+
|
33
|
+
# マイグレーション用スクリプトの生成、relationのクラス定義ファイルの生成
|
34
|
+
mig = @config.prepare_for_migrate(db_scheme_ary, dbconfig_path, dbconfig, relation)
|
35
|
+
mig.output
|
36
|
+
|
37
|
+
# マイグレーション実行
|
38
|
+
ActiveRecord::MigrationContext.new(mig.migrate_dir, ActiveRecord::SchemaMigration).up
|
39
|
+
end
|
40
|
+
|
41
|
+
def integrate(dbconfig, env)
|
42
|
+
connect_time = Arxutils_Sqlite3::Dbutil::Dbconnect.db_connect(@config, dbconfig, env)
|
43
|
+
Dbsetup.new(connect_time)
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete(dbconfig, db_scheme_ary, relation)
|
47
|
+
config_dir = @config.get_config_dir
|
48
|
+
dbconfig_path = Arxutils_Sqlite3::Util.make_dbconfig_path(config_dir, dbconfig)
|
49
|
+
mig = @config.prepare_for_migrate(db_scheme_ary, dbconfig_path, dbconfig, relation)
|
50
|
+
mig.delete_migrate_and_config_and_db
|
51
|
+
end
|
52
|
+
|
53
|
+
def delete_db(dbconfig, db_scheme_ary, relation)
|
54
|
+
config_dir = config.get_config_dir
|
55
|
+
dbconfig_path = Arxutils_Sqlite3::Util.make_dbconfig_path(config_dir, dbconfig)
|
56
|
+
mig = @config.prepare_for_migrate(db_scheme_ary, dbconfig_path, dbconfig, relation)
|
57
|
+
# mig.delete_migrate_config_and_db
|
58
|
+
mig.delete_db
|
59
|
+
end
|
60
|
+
|
61
|
+
def rm_dbconfig(dbconfig)
|
62
|
+
dbconfig_path = @config.make_dbconfig_path(dbconfig)
|
63
|
+
p dbconfig_path
|
64
|
+
FileUtils.rm_f(dbconfig_path)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Enop
|
2
|
+
module Dbutil
|
3
|
+
class Count < ActiveRecord::Base
|
4
|
+
has_many :invalidennblists
|
5
|
+
end
|
6
|
+
|
7
|
+
class Countdatetime < ActiveRecord::Base
|
8
|
+
end
|
9
|
+
|
10
|
+
class Evnb < ActiveRecord::Base
|
11
|
+
end
|
12
|
+
|
13
|
+
class Ennblist < ActiveRecord::Base
|
14
|
+
end
|
15
|
+
|
16
|
+
class Invalidennblist < ActiveRecord::Base
|
17
|
+
belongs_to :ennblist , foreign_key: 'org_id'
|
18
|
+
belongs_to :count , foreign_key: ''
|
19
|
+
end
|
20
|
+
|
21
|
+
class Currentennblist < ActiveRecord::Base
|
22
|
+
belongs_to :ennblist , foreign_key: 'org_id'
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/arxutils_sqlite3.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arxutils_sqlite3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.48
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yasuo kominami
|
@@ -109,47 +109,47 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
117
|
+
version: '3.0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
124
|
+
version: '3.0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: rake
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - "
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
131
|
+
version: '13.0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - "
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
138
|
+
version: '13.0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rubocop
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
145
|
+
version: '1.7'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
152
|
+
version: '1.7'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rubocop-rake
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,9 +217,11 @@ files:
|
|
217
217
|
- exe/arxutils_sqlite3
|
218
218
|
- lib/arxutils_sqlite3.rb
|
219
219
|
- lib/arxutils_sqlite3/arx.rb
|
220
|
+
- lib/arxutils_sqlite3/cli.rb
|
220
221
|
- lib/arxutils_sqlite3/config.rb
|
221
222
|
- lib/arxutils_sqlite3/dbutil.rb
|
222
223
|
- lib/arxutils_sqlite3/dbutil/dbconnect.rb
|
224
|
+
- lib/arxutils_sqlite3/dbutil/dbrelation.rb
|
223
225
|
- lib/arxutils_sqlite3/hier.rb
|
224
226
|
- lib/arxutils_sqlite3/migrate.rb
|
225
227
|
- lib/arxutils_sqlite3/transactstate.rb
|