prick 0.13.0 → 0.17.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da40d1823b2163a2ce84de52d2a41aa222ae87afc6bb7cbe22e2d5045a162fba
4
- data.tar.gz: cee09b71589069b2dbe386afec271ef1677980e0e6d6735462a8c087338e71d9
3
+ metadata.gz: 70b51ae69f1d1cb0c2c27666273b0564d78f950de870104865203362258d40a2
4
+ data.tar.gz: e3b46dbc411282c05977940551246a8bfff7689889648ac7e481974c67ef326f
5
5
  SHA512:
6
- metadata.gz: 1b8f5f478092b60b5745983d911f37e516b24957bcdd978157e97263d97c65857e71b1335dc10a7f38fdd742f27c62f4cd28071e4ff31f53cca4f51e88f55557
7
- data.tar.gz: 7a3efb1a894edfa8b5ca82688b4820126f2898f2448a92d84af49e611b9156bfbf20f34e62deb605ca50cb9fbb57691d6e2ceae2d604fbb6bb6dc3166e751213
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 !Dir.getwd != "/" && !File.exist?(PRICK_VERSION_FILE)
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
- Rdbms.exec_file(database.name, file, user: database.user, schema: schema)
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
- Rdbms.exec_sql(database.name, lines.join("\n"), user: database.user, schema: schema)
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
@@ -59,7 +59,23 @@ module Prick
59
59
  @version = nil
60
60
  end
61
61
 
62
- def clean() recreate end # TODO: Find solution that doesn't involve dropping the database
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
@@ -4,7 +4,7 @@
4
4
 
5
5
  # Required by gem
6
6
  module Prick
7
- VERSION = "0.13.0"
7
+ VERSION = "0.17.0"
8
8
  end
9
9
 
10
10
  # Project related code starts here
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.13.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-03-09 00:00:00.000000000 Z
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.2
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