arxutils_sqlite3 0.1.43 → 0.1.44
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 +1 -1
- data/exe/arxutils_sqlite3 +9 -45
- data/lib/arxutils_sqlite3/dbutil/dbconnect.rb +3 -3
- data/lib/arxutils_sqlite3/util.rb +39 -0
- data/lib/arxutils_sqlite3/version.rb +1 -1
- data/lib/arxutils_sqlite3.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b5f6ede0a6841ea546179192fe18757e9f35669baae096b5c7f0ed9ec79c687
|
4
|
+
data.tar.gz: 592da7e2edf26c4e4a41e7d9d1ed74ebf67ffdb7dddc6e2a2732f3643a545570
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ade5c9990a6c5553a71b62adda473541415bdba26b1c6c7162d2d588e66750d9ebe80367c8efa7bbccff064aa4410a18138fc254a571f14ea27ca2e07b03096
|
7
|
+
data.tar.gz: aedfc8af290c382f5cd2eb4c67dde8b94ef533de95ee5607236a480c0cf0443a1f5a249258efaefdc35193f681f44ab6ce9502232ba388967c85a0eb6e8bd615
|
data/arxutils_sqlite3.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
spec.bindir = "exe"
|
33
33
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
34
|
-
p spec.executables
|
34
|
+
#p spec.executables
|
35
35
|
spec.require_paths = ["lib"]
|
36
36
|
spec.add_runtime_dependency "activesupport"
|
37
37
|
# spec.add_runtime_dependency "erb"
|
data/exe/arxutils_sqlite3
CHANGED
@@ -31,41 +31,6 @@ if File.exist?(Arxutils_Sqlite3::DEST_DBSETUP_FILE)
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
def prepare_for_migrate(env, db_scheme_ary, db_dir, dbconfig_dest_path, opts)
|
36
|
-
migrate_base_dir = Arxutils_Sqlite3::Dbutil::MIGRATE_DIR
|
37
|
-
# migrate用スクリプト格納ディレクトリへのパス
|
38
|
-
migrate_dir = File.join(db_dir, migrate_base_dir)
|
39
|
-
# DB構成ファイルの出力先ディレクトリ
|
40
|
-
dest_config_dir = Arxutils_Sqlite3::Dbutil::CONFIG_DIR
|
41
|
-
dbconfig_src_fname = "#{opts["dbconfig"]}.tmpl"
|
42
|
-
p "dbconfig_dest_path=#{dbconfig_dest_path}"
|
43
|
-
relation = opts[:relation]
|
44
|
-
mig = Arxutils_Sqlite3::Migrate.new(
|
45
|
-
dbconfig_dest_path,
|
46
|
-
dbconfig_src_fname,
|
47
|
-
migrate_dir,
|
48
|
-
db_dir,
|
49
|
-
db_scheme_ary,
|
50
|
-
relation,
|
51
|
-
opts)
|
52
|
-
end
|
53
|
-
|
54
|
-
def make_log_path(db_dir, dbconfig)
|
55
|
-
log_path = ""
|
56
|
-
log_fname = Arxutils_Sqlite3::Dbutil::Dbconnect.make_log_file_name(
|
57
|
-
dbconfig, Arxutils_Sqlite3::Dbutil::DATABASELOG)
|
58
|
-
if db_dir && log_fname
|
59
|
-
# DB用ログファイルへのパス
|
60
|
-
log_path = File.join(db_dir, log_fname)
|
61
|
-
end
|
62
|
-
log_path
|
63
|
-
end
|
64
|
-
|
65
|
-
def make_dbconfig_path(config_dir, dbconfig)
|
66
|
-
File.join( config_dir, "#{dbconfig}.yml")
|
67
|
-
end
|
68
|
-
|
69
34
|
banner = "Usage: bundle exec ruby exe/makemigrate --cmd=(s|c|m|i|d) -y yaml_file --klass=class"
|
70
35
|
|
71
36
|
opts = @opts ? @opts : {}
|
@@ -103,9 +68,9 @@ when "c"
|
|
103
68
|
db_dir = Arxutils_Sqlite3::Dbutil::DB_DIR
|
104
69
|
config_dir = Arxutils_Sqlite3::Dbutil::CONFIG_DIR
|
105
70
|
# DB構成ファイル名
|
106
|
-
dbconfig_path = make_dbconfig_path(config_dir, opts["dbconfig"])
|
71
|
+
dbconfig_path = Arxutils_Sqlite3::Util.make_dbconfig_path(config_dir, opts["dbconfig"])
|
107
72
|
|
108
|
-
mig = prepare_for_migrate(env, db_scheme_ary, db_dir, dbconfig_path, opts)
|
73
|
+
mig = Arxutils_Sqlite3::Util.prepare_for_migrate(env, db_scheme_ary, db_dir, dbconfig_path, opts)
|
109
74
|
mig.make_dbconfig(opts)
|
110
75
|
|
111
76
|
when "m"
|
@@ -130,10 +95,10 @@ when "m"
|
|
130
95
|
|
131
96
|
config_dir = Arxutils_Sqlite3::Dbutil::CONFIG_DIR
|
132
97
|
# DB構成ファイル名
|
133
|
-
dbconfig_path = make_dbconfig_path(config_dir, opts["dbconfig"])
|
98
|
+
dbconfig_path = Arxutils_Sqlite3::Util.make_dbconfig_path(config_dir, opts["dbconfig"])
|
134
99
|
# DBログファイルへのパス
|
135
|
-
log_path = make_log_path(db_dir, opts["dbconfig"])
|
136
|
-
mig = prepare_for_migrate(env, db_scheme_ary, db_dir, dbconfig_path, opts)
|
100
|
+
log_path = Arxutils_Sqlite3::Util.make_log_path(db_dir, opts["dbconfig"])
|
101
|
+
mig = Arxutils_Sqlite3::Util.prepare_for_migrate(env, db_scheme_ary, db_dir, dbconfig_path, opts)
|
137
102
|
mig.process
|
138
103
|
dbconnect = Arxutils_Sqlite3::Dbutil::Dbconnect.new(
|
139
104
|
dbconfig_path,
|
@@ -141,7 +106,7 @@ when "m"
|
|
141
106
|
log_path
|
142
107
|
)
|
143
108
|
connect_time = dbconnect.connect
|
144
|
-
p "connect_time=#{connect_time}"
|
109
|
+
#p "connect_time=#{connect_time}"
|
145
110
|
ActiveRecord::MigrationContext.new(mig.migrate_dir, ActiveRecord::SchemaMigration).up
|
146
111
|
|
147
112
|
when "i"
|
@@ -151,9 +116,9 @@ when "i"
|
|
151
116
|
|
152
117
|
config_dir = Arxutils_Sqlite3::Dbutil::CONFIG_DIR
|
153
118
|
# DB構成ファイルへのパス
|
154
|
-
dbconfig_dest_path = make_dbconfig_path(config_dir, opts["dbconfig"])
|
119
|
+
dbconfig_dest_path = Arxutils_Sqlite3::Util.make_dbconfig_path(config_dir, opts["dbconfig"])
|
155
120
|
# DBログファイルへのパス
|
156
|
-
log_path = make_log_path(db_dir, opts["dbconfig"])
|
121
|
+
log_path = Arxutils_Sqlite3::Util.make_log_path(db_dir, opts["dbconfig"])
|
157
122
|
dbconnect = Arxutils_Sqlite3::Dbutil::Dbconnect.new(
|
158
123
|
dbconfig_dest_path,
|
159
124
|
env,
|
@@ -165,12 +130,11 @@ when "i"
|
|
165
130
|
|
166
131
|
when "d"
|
167
132
|
db_scheme_ary = nil
|
168
|
-
mig = repare_for_migrate(env, db_scheme_ary, opts)
|
133
|
+
mig = Arxutils_Sqlite3::Util.repare_for_migrate(env, db_scheme_ary, opts)
|
169
134
|
mig.delete_migrate_config_and_db
|
170
135
|
|
171
136
|
else
|
172
137
|
puts "Invalid command(#{opts["cmd"]}) specified!!"
|
173
138
|
end
|
174
|
-
|
175
139
|
#
|
176
140
|
|
@@ -50,10 +50,10 @@ module Arxutils_Sqlite3
|
|
50
50
|
def connect
|
51
51
|
unless @connect_time
|
52
52
|
begin
|
53
|
-
p "@dbconfig_dest_path=#{@dbconfig_dest_path}"
|
53
|
+
#p "@dbconfig_dest_path=#{@dbconfig_dest_path}"
|
54
54
|
dbconfig = Ykxutils.yaml_load_file_compati(@dbconfig_dest_path)
|
55
|
-
p "dbconfig=#{dbconfig}"
|
56
|
-
p "@env=#{@env}"
|
55
|
+
#p "dbconfig=#{dbconfig}"
|
56
|
+
#p "@env=#{@env}"
|
57
57
|
ActiveRecord::Base.establish_connection(dbconfig[@env])
|
58
58
|
ActiveRecord::Base.logger = Logger.new(@log_path)
|
59
59
|
@connect_time = DateTime.now.new_offset
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Arxutils_Sqlite3
|
2
|
+
class Util
|
3
|
+
# migrateの準備
|
4
|
+
def self.prepare_for_migrate(env, db_scheme_ary, db_dir, dbconfig_dest_path, opts)
|
5
|
+
migrate_base_dir = Dbutil::MIGRATE_DIR
|
6
|
+
# migrate用スクリプト格納ディレクトリへのパス
|
7
|
+
migrate_dir = File.join(db_dir, migrate_base_dir)
|
8
|
+
# DB構成ファイルの出力先ディレクトリ
|
9
|
+
dest_config_dir = Dbutil::CONFIG_DIR
|
10
|
+
dbconfig_src_fname = "#{opts["dbconfig"]}.tmpl"
|
11
|
+
relation = opts[:relation]
|
12
|
+
mig = Migrate.new(
|
13
|
+
dbconfig_dest_path,
|
14
|
+
dbconfig_src_fname,
|
15
|
+
migrate_dir,
|
16
|
+
db_dir,
|
17
|
+
db_scheme_ary,
|
18
|
+
relation,
|
19
|
+
opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
# DBログファイルへのパスの作成
|
23
|
+
def self.make_log_path(db_dir, dbconfig)
|
24
|
+
log_path = ""
|
25
|
+
log_fname = Dbutil::Dbconnect.make_log_file_name(
|
26
|
+
dbconfig, Dbutil::DATABASELOG)
|
27
|
+
if db_dir && log_fname
|
28
|
+
# DB用ログファイルへのパス
|
29
|
+
log_path = File.join(db_dir, log_fname)
|
30
|
+
end
|
31
|
+
log_path
|
32
|
+
end
|
33
|
+
|
34
|
+
# DB構成ファイルへのパスの作成
|
35
|
+
def self.make_dbconfig_path(config_dir, dbconfig)
|
36
|
+
File.join( config_dir, "#{dbconfig}.yml")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/arxutils_sqlite3.rb
CHANGED
@@ -15,6 +15,7 @@ require_relative "arxutils_sqlite3/hier"
|
|
15
15
|
require_relative "arxutils_sqlite3/migrate"
|
16
16
|
require_relative "arxutils_sqlite3/dbutil"
|
17
17
|
require_relative "arxutils_sqlite3/migrate"
|
18
|
+
require_relative "arxutils_sqlite3/util"
|
18
19
|
|
19
20
|
module Arxutils_Sqlite3
|
20
21
|
TOP_DIR = Pathname(__FILE__).parent
|
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.44
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yasuo kominami
|
@@ -222,6 +222,7 @@ files:
|
|
222
222
|
- lib/arxutils_sqlite3/hier.rb
|
223
223
|
- lib/arxutils_sqlite3/migrate.rb
|
224
224
|
- lib/arxutils_sqlite3/transactstate.rb
|
225
|
+
- lib/arxutils_sqlite3/util.rb
|
225
226
|
- lib/arxutils_sqlite3/version.rb
|
226
227
|
- lib/template/config/mysql.tmpl
|
227
228
|
- lib/template/config/sqlite3.tmpl
|