prick 0.20.4 → 0.20.5

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: 16661e75996622c695a8c0d0d6ed65f383b98f825251c21cc6c357d8a64e030a
4
- data.tar.gz: 9c3dc5d7c43b129e5c01808ae8e237ef3ad9cb87d792da711c4dad5f410f5eaf
3
+ metadata.gz: 546c5ddee2590544bc4d77eeac96db85cbe2bcf1f752a310ead0623bd02af69c
4
+ data.tar.gz: fe5ea7a76834b33d4e50664fa379d617b7820b89b82907613fa9d7e4be9d81b4
5
5
  SHA512:
6
- metadata.gz: 97ea15b9490ababf188bb81c1355e70dbc805b55d03cf22b24df43971fe5d0cd4c8c74e9defc9faa3b8ecdae74c3188f0371d9ab668e1f07b953dd7394ef3265
7
- data.tar.gz: cb4a420a3463b16371f0b89306471ecd7ae0cb1a8c11240b1a96d445248050c7b9e913671bcc882255168fcf3b3334ab56a9e9243dcd3eeab796e566ab5a1afd
6
+ metadata.gz: f7c3c32abf035d32c787df578b7ba9a6b9f87cac4b76afb37f3293621a4dc3c7b098bf102e64fe0c9959cca75559d0b8f5273833067b76101b82f3439598bad9
7
+ data.tar.gz: b7628d68390952963b185e68bdcb8431fa86a1bc7e847ba546eaed57525ac748dedc951f6619c202dc192fe5bd03e841699d75f4e10746b013a86a44f4a79ed3
data/lib/prick/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prick
4
- VERSION = "0.20.4"
4
+ VERSION = "0.20.5"
5
5
  end
@@ -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(database) { |conn|
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
-
@@ -4,7 +4,7 @@ require 'builder/builder.rb'
4
4
 
5
5
  module Prick::SubCommand
6
6
  def self.teardown(database, username)
7
- conn = PgConn.new # Superuser connection
7
+ conn = PgConn.new "postgres" # Superuser connection
8
8
  if conn.rdbms.exist? database
9
9
  conn.rdbms.drop database
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.4
4
+ version: 0.20.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen