arxutils_sqlite3 0.1.54 → 0.1.56
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/arxutils_sqlite3 +14 -15
- data/lib/arxutils_sqlite3/cli.rb +35 -23
- data/lib/arxutils_sqlite3/migrate.rb +0 -1
- data/lib/arxutils_sqlite3/rake_task.rb +5 -0
- data/lib/arxutils_sqlite3/version.rb +1 -1
- data/lib/dbacrecord.rb +3 -3
- data/lib/template/acrecord/acrecord_current.tmpl +1 -1
- data/lib/template/acrecord/acrecord_invalid.tmpl +2 -2
- data/lib/template/acrecord/base.tmpl +1 -1
- data/lib/template/acrecord/current.tmpl +1 -1
- data/lib/template/acrecord/db_scheme/dbsetup.tmpl +2 -2
- data/lib/template/acrecord/noitem.tmpl +2 -2
- data/memo.md +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c61855dd1cb824e99683ddbe8ea74085dccfdceb07daf5d875c17ae970ba764
|
4
|
+
data.tar.gz: 58b003297e61ab90072846de1b34836ac0a7461d3c611dee991224c6d07c0354
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 123d78945f9f2f2b8e23f944f111d069e92c94551523f51a13dce6e928722f031a3c399b66eb87be4973ec2f372bdb067ea78b36ea1df115d9382bccec9c70df
|
7
|
+
data.tar.gz: '08dcc25d6c3fc43b343ef65d08df6bdf789a6eed391f0af73deb5fbe348d8a8baca7a3086d19ab21bd42edd99cf1ab75c0d0b1da6012276c659589d99ff74292'
|
data/Gemfile.lock
CHANGED
data/exe/arxutils_sqlite3
CHANGED
@@ -13,10 +13,10 @@ opts, klass = config.setupx(self)
|
|
13
13
|
# p klass
|
14
14
|
# exit
|
15
15
|
|
16
|
-
banner = "Usage: bundle exec arxutils_sqlite3 --cmd=(s|cds|co|c|f|m|a|d|b|y) -y yaml_file --klass=class"
|
16
|
+
banner = "Usage: bundle exec arxutils_sqlite3 --cmd=(s|cds|co|c|f|m|a|d|b|y|dm) -y yaml_file --klass=class"
|
17
17
|
|
18
18
|
Simpleoptparse::Simpleoptparse.parse(ARGV, opts, banner, Arxutils_Sqlite3::VERSION, nil) do |parser|
|
19
|
-
parser.on("--cmd X", %w[s cds co c f m a d b y]) { |x| opts["cmd"] = x }
|
19
|
+
parser.on("--cmd X", %w[s cds co c f m a d b y dm]) { |x| opts["cmd"] = x }
|
20
20
|
parser.on("-y yaml_file", "--yaml yaml_file") { |x| opts["yaml"] = x }
|
21
21
|
parser.on("--klass klass") { |x| opts["klass"] = x }
|
22
22
|
end
|
@@ -25,7 +25,10 @@ dbconfig = Arxutils_Sqlite3::Config::DBCONFIG_SQLITE3
|
|
25
25
|
env = ENV.fetch("ENV", nil)
|
26
26
|
env ||= "production"
|
27
27
|
|
28
|
-
|
28
|
+
acrecord = opts[:acrecord]
|
29
|
+
yaml_fname = opts["yaml"]
|
30
|
+
klass = opts["klass"]
|
31
|
+
cli = Arxutils_Sqlite3::Cli.new(config, dbconfig, env, acrecord, yaml_fname, klass)
|
29
32
|
|
30
33
|
case opts["cmd"]
|
31
34
|
when "s"
|
@@ -44,20 +47,16 @@ when "co"
|
|
44
47
|
cli.copy_opts_file
|
45
48
|
|
46
49
|
when "c"
|
47
|
-
|
48
|
-
cli.makeconfig(acrecord, banner, 30, opts)
|
50
|
+
cli.makeconfig(opts)
|
49
51
|
|
50
52
|
when "f"
|
51
|
-
yaml_fname = opts["yaml"]
|
52
|
-
acrecord = opts[:acrecord]
|
53
53
|
if yaml_fname.nil? || yaml_fname.strip == ""
|
54
54
|
puts banner
|
55
55
|
exit 40
|
56
56
|
end
|
57
57
|
yaml_pn = Pathname.new(yaml_fname)
|
58
58
|
config.check_file_not_exist(yaml_pn, banner, 55)
|
59
|
-
cli.
|
60
|
-
|
59
|
+
cli.make_migrate_script
|
61
60
|
when "m"
|
62
61
|
cli.migrate
|
63
62
|
|
@@ -65,17 +64,17 @@ when "a"
|
|
65
64
|
cli.acr
|
66
65
|
|
67
66
|
when "d"
|
68
|
-
|
69
|
-
acrecord = opts["acrecord"]
|
70
|
-
cli.delete(db_scheme_ary, acrecord)
|
67
|
+
cli.delete
|
71
68
|
|
72
69
|
when "b"
|
73
|
-
|
74
|
-
acrecord = opts["acrecord"]
|
75
|
-
cli.delete_db(db_scheme_ary, acrecord)
|
70
|
+
cli.delete_db
|
76
71
|
|
77
72
|
when "y"
|
78
73
|
cli.delete_setting_yaml
|
74
|
+
|
75
|
+
when "dm"
|
76
|
+
cli.delete_migrate
|
77
|
+
|
79
78
|
else
|
80
79
|
puts "Invalid command(#{opts["cmd"]}) specified!!"
|
81
80
|
end
|
data/lib/arxutils_sqlite3/cli.rb
CHANGED
@@ -1,10 +1,23 @@
|
|
1
1
|
module Arxutils_Sqlite3
|
2
2
|
# CLI用クラス
|
3
3
|
class Cli
|
4
|
-
def initialize(config, dbconfig, env)
|
4
|
+
def initialize(config, dbconfig, env, acrecord, yaml_fname, klass)
|
5
5
|
@config = config
|
6
6
|
@dbconfig = dbconfig
|
7
7
|
@env = env
|
8
|
+
@acrecord = acrecord
|
9
|
+
@dbconfig_path = @config.make_dbconfig_path(@dbconfig)
|
10
|
+
|
11
|
+
@db_scheme_ary = nil
|
12
|
+
if yaml_fname && yaml_fname.strip != ""
|
13
|
+
yaml_pn = Pathname.new(yaml_fname)
|
14
|
+
@db_scheme_ary = YAML.load_file(yaml_pn)
|
15
|
+
end
|
16
|
+
@mig = @config.prepare_for_migrate(@db_scheme_ary, @dbconfig_path, @dbconfig, @acrecord)
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup_for_migrate(yaml_pn, klass)
|
20
|
+
|
8
21
|
end
|
9
22
|
|
10
23
|
def setup(klass)
|
@@ -29,24 +42,22 @@ module Arxutils_Sqlite3
|
|
29
42
|
@config.copy_opts_file
|
30
43
|
end
|
31
44
|
|
32
|
-
def
|
45
|
+
def setup_for_migrate
|
33
46
|
db_scheme_ary = nil
|
34
47
|
dbconfig_path = @config.make_dbconfig_path(@dbconfig)
|
35
48
|
# @config.check_file_exist(dbconfig_path, banner, exit_code)
|
36
|
-
|
37
|
-
mig.make_dbconfig(opts)
|
49
|
+
@config.prepare_for_migrate(db_scheme_ary, dbconfig_path, @dbconfig, @acrecord)
|
38
50
|
end
|
39
51
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
dest_dbsetup_file = @config.dest_dbsetup_file
|
45
|
-
@config.make_dbsetup_file(db_scheme_ary, acrecord, klass, dest_dbsetup_file)
|
52
|
+
def makeconfig(opts)
|
53
|
+
@mig.make_dbconfig(opts)
|
54
|
+
end
|
46
55
|
|
56
|
+
def make_migrate_script
|
57
|
+
@dest_dbsetup_file = @config.dest_dbsetup_file
|
58
|
+
@config.make_dbsetup_file(@db_scheme_ary, @acrecord, @klass, @dest_dbsetup_file)
|
47
59
|
# マイグレーション用スクリプトの生成、acrecordのクラス定義ファイルの生成
|
48
|
-
mig
|
49
|
-
mig.output
|
60
|
+
@mig.output
|
50
61
|
end
|
51
62
|
|
52
63
|
# マイグレーション実行
|
@@ -75,25 +86,26 @@ module Arxutils_Sqlite3
|
|
75
86
|
ret
|
76
87
|
end
|
77
88
|
|
78
|
-
def delete
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
89
|
+
def delete
|
90
|
+
@mig.delete_migrate_and_config_and_db
|
91
|
+
end
|
92
|
+
|
93
|
+
def delete_db
|
94
|
+
@mig.delete_db
|
83
95
|
end
|
84
96
|
|
85
|
-
def
|
86
|
-
|
87
|
-
dbconfig_path = Arxutils_Sqlite3::Util.make_dbconfig_path(config_dir, @dbconfig)
|
88
|
-
mig = @config.prepare_for_migrate(db_scheme_ary, dbconfig_path, @dbconfig, acrecord)
|
89
|
-
# mig.delete_migrate_config_and_db
|
90
|
-
mig.delete_db
|
97
|
+
def delete_nigrate
|
98
|
+
@mig.delete_migrate
|
91
99
|
end
|
92
100
|
|
93
101
|
def delete_setting_yaml
|
94
102
|
FileUtils.rm_f(@config.setting_yaml_file)
|
95
103
|
end
|
96
104
|
|
105
|
+
def delete_migrate
|
106
|
+
@mig.delete_migrate
|
107
|
+
end
|
108
|
+
|
97
109
|
def rm_dbconfig
|
98
110
|
dbconfig_path = @config.make_dbconfig_path(@dbconfig)
|
99
111
|
# p dbconfig_path
|
data/lib/dbacrecord.rb
CHANGED
@@ -14,12 +14,12 @@ module Dbutil
|
|
14
14
|
end
|
15
15
|
|
16
16
|
class Invalidxenoplist < ActiveRecord::Base
|
17
|
-
belongs_to :xenoplist, foreign_key:
|
18
|
-
belongs_to :count, foreign_key:
|
17
|
+
belongs_to :xenoplist, foreign_key: "org_id"
|
18
|
+
belongs_to :count, foreign_key: ""
|
19
19
|
end
|
20
20
|
|
21
21
|
class Currentxenoplist < ActiveRecord::Base
|
22
|
-
belongs_to :xenoplist
|
22
|
+
belongs_to :xenoplist, foreign_key: "org_id"
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -1,4 +1,4 @@
|
|
1
1
|
class Invalid<%= @data[:classname_downcase] %> < ActiveRecord::Base
|
2
|
-
belongs_to :<%= @data[:classname_downcase] %>, foreign_key:
|
3
|
-
belongs_to :<%= @data[:count_classname_downcase] %>, foreign_key:
|
2
|
+
belongs_to :<%= @data[:classname_downcase] %>, foreign_key: "org_id"
|
3
|
+
belongs_to :<%= @data[:count_classname_downcase] %>, foreign_key: "<%= @data[:count_field] %>"
|
4
4
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Create<%= @data[:classname] %> < ActiveRecord::Migration[<%= @data[:ar_version] %>]
|
2
2
|
def self.up
|
3
3
|
create_table :<%= @data[:plural] %> do |t|
|
4
|
-
<% @data[:ary].each do |x| %>
|
4
|
+
<% @data[:ary].each do |x| %>
|
5
5
|
t.column :<%= x.name %>, :<%= x.type %>, :null => <%= x.null %>
|
6
6
|
<% end %>
|
7
7
|
t.timestamps null: false
|
@@ -2,7 +2,7 @@ class CreateCurrent<%= @data[:classname_downcase] %> < ActiveRecord::Migration[<
|
|
2
2
|
def self.up
|
3
3
|
execute <<-SQL
|
4
4
|
CREATE VIEW current<%= @data[:plural] %> AS SELECT id as org_id,
|
5
|
-
<%= @data[:ary].map{|x| x.name }.join(" , ") %>
|
5
|
+
<%= @data[:ary].map{|x| x.name }.join(" , ") %>
|
6
6
|
FROM <%= @data[:plural] %> where not exists (select * from invalid<%= @data[:plural] %> where invalid<%= @data[:plural] %>.org_id = <%= @data[:plural] %>.id )
|
7
7
|
SQL
|
8
8
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "../lib/dbacrecord"
|
2
2
|
|
3
3
|
class Dbsetup
|
4
4
|
def initialize(connect_time)
|
5
5
|
@connect_time = connect_time
|
6
|
-
@ct = <%= klass %>::Dbutil::Countdatetime.create(
|
6
|
+
@ct = <%= klass %>::Dbutil::Countdatetime.create(countdatetime: @connect_time)
|
7
7
|
@hs_by_notebook = {}
|
8
8
|
@hs_by_id = {}
|
9
9
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class Create<%= @data[:classname] %> < ActiveRecord::Migration[<%= @data[:ar_version] %>]
|
2
2
|
def self.up
|
3
3
|
create_table :<%= @data[:plural] %> do |t|
|
4
|
-
<% @data[:ary].each do |x| %>
|
4
|
+
<% @data[:ary].each do |x| %>
|
5
5
|
t.column :<%= x.name %>, :<%= x.type %>, :null => <%= x.null %>
|
6
|
-
<% end %>
|
6
|
+
<% end %>
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
data/memo.md
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.56
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yasuo kominami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -243,6 +243,7 @@ files:
|
|
243
243
|
- lib/template/acrecord/noitem.tmpl
|
244
244
|
- lib/template/config/mysql.tmpl
|
245
245
|
- lib/template/config/sqlite3.tmpl
|
246
|
+
- memo.md
|
246
247
|
homepage: https://ykominami.github.io/arxutils_sqlite3/
|
247
248
|
licenses:
|
248
249
|
- MIT
|