prick 0.20.4 → 0.20.7
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/exe/prick +1 -1
- data/lib/prick/version.rb +1 -1
- data/lib/subcommand/prick-drop.rb +3 -3
- data/lib/subcommand/prick-make.rb +0 -113
- data/lib/subcommand/prick-teardown.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fc90c635042f5a0b8e8329a091cf301b1568ec47ea8744ef75dbc5aff60ea12
|
4
|
+
data.tar.gz: 9b7e015d3a5f077e0e2c88ed5a557d1efa89488e9a8c9e268beb1c5353351383
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd60b2adcc42237c6651606905d4d9b4bfb9621839ebe94e91087e6bee923f6c98dabe1c929066c75cbe853e4bad66cd9eda95249c09fe7e3a69d5dfacdbedd3
|
7
|
+
data.tar.gz: 357dcd9b4bc147479304beaabaef912e30a616a18f3048a50fff0e077c1ee32b686769d1ecdefbc371620dbca637d2037a2142e1d9562c5ca3b8736d5c0126ee
|
data/exe/prick
CHANGED
@@ -12,7 +12,7 @@ begin
|
|
12
12
|
compile_cache_iseq: true, # Compile Ruby code into ISeq cache, breaks coverage reporting.
|
13
13
|
compile_cache_yaml: true # Compile YAML into a cache
|
14
14
|
)
|
15
|
-
|
15
|
+
# Bootsnap.instrumentation = ->(event, path) { puts "#{event} #{path}" }
|
16
16
|
end
|
17
17
|
|
18
18
|
require 'prick.rb'
|
data/lib/prick/version.rb
CHANGED
@@ -4,18 +4,18 @@ require 'builder/builder.rb'
|
|
4
4
|
|
5
5
|
module Prick::SubCommand
|
6
6
|
def self.drop_users(database)
|
7
|
-
PgConn.new(
|
7
|
+
PgConn.new("postgres") { |conn|
|
8
8
|
users = conn.role.list(database: database)
|
9
9
|
conn.role.drop(users, cascade: true)
|
10
10
|
}
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.drop_database(database)
|
14
|
-
PgConn.new { |conn| conn.rdbms.drop database }
|
14
|
+
PgConn.new("postgres") { |conn| conn.rdbms.drop database }
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.drop_all(database)
|
18
|
-
PgConn.new { |conn|
|
18
|
+
PgConn.new("postgres") { |conn|
|
19
19
|
users = conn.role.list(database: database)
|
20
20
|
PgConn.new(database) { |db| db.role.drop(users, cascade: true) }
|
21
21
|
conn.rdbms.drop database
|
@@ -87,116 +87,3 @@ module Prick::SubCommand
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
__END__
|
91
|
-
require 'prick_build.rb'
|
92
|
-
|
93
|
-
require 'pg_conn'
|
94
|
-
|
95
|
-
require 'ruby-prof'
|
96
|
-
|
97
|
-
DATABASE = "mikras"
|
98
|
-
USERNAME = "mikras"
|
99
|
-
|
100
|
-
#PROFILE = true
|
101
|
-
PROFILE = false
|
102
|
-
TIME = true
|
103
|
-
#TIME = false
|
104
|
-
|
105
|
-
EPOCH = Time.at(0).utc
|
106
|
-
|
107
|
-
schema = ARGV.first
|
108
|
-
|
109
|
-
time "Program" do
|
110
|
-
RubyProf.start if PROFILE
|
111
|
-
begin
|
112
|
-
conn = nil
|
113
|
-
builder = nil
|
114
|
-
built_at = EPOCH
|
115
|
-
clean = false
|
116
|
-
create_schema = true
|
117
|
-
|
118
|
-
time "Load build object" do
|
119
|
-
PgConn.new { |super_conn|
|
120
|
-
if super_conn.rdbms.exist? DATABASE
|
121
|
-
conn = PgConn.new(DATABASE)
|
122
|
-
if conn.schema.exist_table? "prick", "versions"
|
123
|
-
built_at = conn.value("select built_at from prick.versions")
|
124
|
-
end
|
125
|
-
else
|
126
|
-
super_conn.rdbms.create DATABASE, owner: USERNAME
|
127
|
-
conn = PgConn.new(DATABASE)
|
128
|
-
clean = true
|
129
|
-
end
|
130
|
-
}
|
131
|
-
|
132
|
-
builder = Prick::Build::Builder.new(conn, "schema", clean)
|
133
|
-
|
134
|
-
if schema
|
135
|
-
builder.pool.after_schema(schema).each { |schema|
|
136
|
-
conn.schema.drop(schema, cascade: true)
|
137
|
-
builder.pool.delete_schema(schema)
|
138
|
-
}
|
139
|
-
end
|
140
|
-
|
141
|
-
touched_nodes = builder.nodes.select { |node| File.mtime(node.path) > built_at }
|
142
|
-
touched_phases = touched_nodes.map(&:phase).uniq.compact
|
143
|
-
touched_schema = touched_nodes.first&.schema
|
144
|
-
missing_schema = builder.schemas.find { |schema| !conn.schema.exist?(schema) }
|
145
|
-
build_schema = builder.schemas.find { |schema| [touched_schema, missing_schema].include? schema }
|
146
|
-
|
147
|
-
# puts "touched_nodes : #{touched_nodes.size} nodes"
|
148
|
-
# puts "touched_phases: #{touched_phases.inspect}"
|
149
|
-
# puts "touched_schema: #{touched_schema.inspect}"
|
150
|
-
# puts "missing_schema: #{missing_schema.inspect}"
|
151
|
-
# puts "build_schema : #{build_schema.inspect}"
|
152
|
-
|
153
|
-
# builder.pool.dump
|
154
|
-
|
155
|
-
if build_schema.nil?
|
156
|
-
puts "#{DATABASE} is up to date"
|
157
|
-
exit
|
158
|
-
end
|
159
|
-
|
160
|
-
if touched_phases.include?(:decl) || touched_phases.empty?
|
161
|
-
schemas = [build_schema] + builder.pool.after_schema(build_schema)
|
162
|
-
schemas.each { |schema| conn.schema.drop(schema, cascade: true) }
|
163
|
-
builder.pool.delete_schema(builder.pool.before_schema(build_schema))
|
164
|
-
elsif touched_phases.include?(:init) || touched_phases.include?(:term)
|
165
|
-
builder.pool.clear(:decl, :seed)
|
166
|
-
create_schema = false
|
167
|
-
elsif touched_phases.include?(:seed)
|
168
|
-
builder.pool.clear(:init, :decl, :term)
|
169
|
-
create_schema = false
|
170
|
-
end
|
171
|
-
|
172
|
-
# builder.pool.dump
|
173
|
-
builder.group
|
174
|
-
end
|
175
|
-
|
176
|
-
# builder.dump
|
177
|
-
# p builder.schemas
|
178
|
-
# exit
|
179
|
-
|
180
|
-
time "Execute build object" do
|
181
|
-
builder.execute(conn, create_schema: create_schema)
|
182
|
-
end
|
183
|
-
|
184
|
-
rescue Prick::Build::Error => ex
|
185
|
-
$stderr.puts ex.message
|
186
|
-
exit 1
|
187
|
-
|
188
|
-
rescue Command::Error => ex
|
189
|
-
$stderr.puts ex.message
|
190
|
-
exit 1
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
if PROFILE
|
195
|
-
profile = RubyProf.stop
|
196
|
-
# printer = RubyProf::GraphHtmlPrinter.new(profile)
|
197
|
-
printer = RubyProf::CallStackPrinter.new(profile)
|
198
|
-
File.open("t.html", "w") { |file|
|
199
|
-
printer.print(file, :min_percent => 2)
|
200
|
-
}
|
201
|
-
end
|
202
|
-
|