prick 0.13.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO +3 -0
- data/exe/prick +1 -1
- data/lib/prick/builder.rb +24 -3
- data/lib/prick/command.rb +1 -1
- data/lib/prick/database.rb +17 -1
- data/lib/prick/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70b51ae69f1d1cb0c2c27666273b0564d78f950de870104865203362258d40a2
|
4
|
+
data.tar.gz: e3b46dbc411282c05977940551246a8bfff7689889648ac7e481974c67ef326f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0431efaa5b92fe0497f642bb5bd4f115f533417122c9f7f71d6de17aa7c65128d79c4a74cfe82ac8fa18b88d9b3aff6905744a3129f62b63f865c64d0e63292f
|
7
|
+
data.tar.gz: 8e01993d41040f3d4db9f10d4aa461b420b81a5116836ba1cbb0cb298b75b2e9beaeb61ce3982ed21496ee459ab76e3f28ddf98c6f40fa17ad28c5f49ffcc97e
|
data/TODO
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
|
2
|
+
o Add a top-level 'global' directory for stuff that doesn't belong to a schema or that
|
3
|
+
require superuser privileges. prick-build should then execute the content of that
|
4
|
+
directory first before switching to the database user
|
2
5
|
o Check for commits to tags
|
3
6
|
o Accumulate version history in prick.versions instead of just having the newest
|
4
7
|
o Using rc's in migration syntax: fork-version-fork-version.rc1 ?
|
data/exe/prick
CHANGED
@@ -198,7 +198,7 @@ begin
|
|
198
198
|
# Change to parent directory containing the Prick version file if not found
|
199
199
|
# in the current directory
|
200
200
|
program.current_directory = Dir.getwd
|
201
|
-
while
|
201
|
+
while Dir.getwd != "/" && !File.exist?(PRICK_VERSION_FILE)
|
202
202
|
Dir.chdir("..")
|
203
203
|
end
|
204
204
|
|
data/lib/prick/builder.rb
CHANGED
@@ -19,7 +19,7 @@ module Prick
|
|
19
19
|
# When a resource match a directory, the directory can contain a special
|
20
20
|
# default resource ('build' or 'migrate') that takes over the rest of the
|
21
21
|
# build process for that directory. Typically, you'll use the 'build.yml' or
|
22
|
-
# 'migrate.yml' to control the build order of the other resources If a
|
22
|
+
# 'migrate.yml' to control the build order of the other resources. If a
|
23
23
|
# directory doesn't contain a build resource, the resources in the directory
|
24
24
|
# are built in alphabetic order
|
25
25
|
#
|
@@ -38,6 +38,7 @@ module Prick
|
|
38
38
|
@default = default
|
39
39
|
@execute = true
|
40
40
|
@lines = []
|
41
|
+
@cwd = Dir.getwd # used in error messages
|
41
42
|
end
|
42
43
|
|
43
44
|
def build(subject = default, execute: true)
|
@@ -67,7 +68,13 @@ module Prick
|
|
67
68
|
# puts "do_sql(#{path})"
|
68
69
|
do_dir(path) { |file|
|
69
70
|
if @execute
|
70
|
-
|
71
|
+
begin
|
72
|
+
Rdbms.exec_file(database.name, file, user: database.user, schema: schema)
|
73
|
+
rescue Command::Error => ex
|
74
|
+
$stderr.puts ex.stderr
|
75
|
+
$stderr.puts "in #{reldir}/#{file}"
|
76
|
+
exit 1
|
77
|
+
end
|
71
78
|
else
|
72
79
|
@lines += IO.readlines(file).map(&:chomp)
|
73
80
|
end
|
@@ -80,7 +87,13 @@ module Prick
|
|
80
87
|
do_dir(path) { |file|
|
81
88
|
lines = Command.command "./#{file} #{database.name} #{database.user}" # FIXME Security
|
82
89
|
if @execute
|
83
|
-
|
90
|
+
begin
|
91
|
+
Rdbms.exec_sql(database.name, lines.join("\n"), user: database.user, schema: schema)
|
92
|
+
rescue Command::Error => ex
|
93
|
+
$stderr.puts ex.stderr
|
94
|
+
$stderr.puts "from #{reldir}/#{file}"
|
95
|
+
exit 1
|
96
|
+
end
|
84
97
|
else
|
85
98
|
@lines += lines
|
86
99
|
end
|
@@ -130,6 +143,14 @@ module Prick
|
|
130
143
|
end
|
131
144
|
}
|
132
145
|
end
|
146
|
+
|
147
|
+
private
|
148
|
+
# Return the relative path to the current directory from the directory of
|
149
|
+
# the time of the instantiation of the Builder object. Used in error
|
150
|
+
# messages
|
151
|
+
def reldir
|
152
|
+
Dir.getwd.sub(/^#{@cwd}\//, "")
|
153
|
+
end
|
133
154
|
end
|
134
155
|
|
135
156
|
class MigrationBuilder < Builder
|
data/lib/prick/command.rb
CHANGED
@@ -55,7 +55,7 @@ module Command
|
|
55
55
|
@status = Process.waitpid2(pid)[1].exitstatus
|
56
56
|
|
57
57
|
out = pr[0].readlines.collect { |line| line.chop }
|
58
|
-
err = pe[0].readlines.collect { |line| line.chop }
|
58
|
+
err = pe[0].readlines.collect { |line| line.chop }.grep_v(/^NOTICE:/)
|
59
59
|
|
60
60
|
pw[1].close
|
61
61
|
pr[0].close
|
data/lib/prick/database.rb
CHANGED
@@ -59,7 +59,23 @@ module Prick
|
|
59
59
|
@version = nil
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
# Hollow-out a database without dropping it. This is useful compared to a
|
63
|
+
# simple drop database since it wont block on other sessions wont block
|
64
|
+
def clean()
|
65
|
+
if exist?
|
66
|
+
schemas = Rdbms.select_values(
|
67
|
+
"postgres",
|
68
|
+
"select nspname from pg_namespace where nspowner != 10")
|
69
|
+
for schema in schemas
|
70
|
+
Rdbms.exec_sql(name, "drop schema \"#{schema}\" cascade")
|
71
|
+
end
|
72
|
+
Rdbms.exec_sql(name, "drop schema if exists public cascade")
|
73
|
+
Rdbms.exec_sql(name, "create schema public authorization postgres")
|
74
|
+
Rdbms.exec_sql(name, "grant usage, create on schema public to public")
|
75
|
+
else
|
76
|
+
create
|
77
|
+
end
|
78
|
+
end
|
63
79
|
|
64
80
|
def to_s() name end
|
65
81
|
end
|
data/lib/prick/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shellopts
|
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
- !ruby/object:Gem::Version
|
156
156
|
version: '0'
|
157
157
|
requirements: []
|
158
|
-
rubygems_version: 3.1.
|
158
|
+
rubygems_version: 3.1.4
|
159
159
|
signing_key:
|
160
160
|
specification_version: 4
|
161
161
|
summary: A release control and management system for postgresql
|