prick 0.20.10 → 0.20.13

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: 665b4f6868f55f1bbf9dc49d361e61c48aed945e98da96626115f6cca8abb7bc
4
- data.tar.gz: 81fe9b58da6fe6cbe800d7027718b0b77ae025799600ce4ba62b900a482d70d9
3
+ metadata.gz: 4435f17e31e98bc0c62c1f7c92818f71f059bc308522ab1ed8ac6acb17825768
4
+ data.tar.gz: aaaf83164a0de30d6a134cc12159cf5fed858806a68e4dba9738da93abd24e15
5
5
  SHA512:
6
- metadata.gz: 51fc6f79ee515714665e830efc923382f13b79d4fec59785c5776a7ed6f6ea0e42ceb0bda0550a73f21086aa01b95c8881643db02fa4a0306bc7e8cc77cb04b0
7
- data.tar.gz: dfd428a987b78fdecf564b3e394436460f1d351dce5442c121967e4672010a5640af89019a01756054e8e9ef59c3548acfbeab51531f2d0979d6f84486710de9
6
+ metadata.gz: 0b6939f154a1e04af830c9bad778deb871f6573dd729afebf776fad34b06bbda1d6debe11b3d38278ec1f09357a6218723e70e0983a93dd6f3f6db2c4311fb5e
7
+ data.tar.gz: c291aeef50d1e5a133c47c7908653762da31d047852bcdfcfe19a0a97114efeb3118f9d2c759466621ece995120e3380107b57e97614410cbc82b18f813a1d7c
data/TODO CHANGED
@@ -1,3 +1,14 @@
1
+ o Fix that enum references are not created:
2
+
3
+ system_roles
4
+ - &app_registry_anon_system_role
5
+ system: APP_REGISTRY # <---------------------------- Creates a dangling reference
6
+ rolename: app_registry_anon_role
7
+ ordinal: 1
8
+ permissions:
9
+ - *app_registry_anon_permission
10
+
11
+
1
12
 
2
13
  o Store fox.state, reflections, and reflections in the database so third-party
3
14
  programs can use them when testing
data/exe/prick CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #$LOAD_PATH.unshift "/home/clr/prj/shellopts/lib"
4
+ #$LOAD_PATH.unshift "/home/clr/prj/pg_graph/lib"
4
5
 
5
6
  require 'bootsnap'
6
7
  begin
data/lib/builder/batch.rb CHANGED
@@ -102,11 +102,12 @@ module Prick
102
102
  files = nodes.map(&:path)
103
103
 
104
104
  # Load meta object
105
- meta = PgMeta.new(conn)
105
+ meta = PgMeta.new(conn, exclude_schemas: builder.pg_graph_ignore_schemas)
106
106
 
107
107
  # Create type object
108
108
  type = PgGraph::Type.new(meta, builder.reflections_file)
109
109
 
110
+ # Timer
110
111
  t_type.stop
111
112
  t_fox = Timer.new " Parse files"
112
113
 
@@ -126,6 +127,7 @@ module Prick
126
127
  # Dump state file
127
128
  fox.write_state(FOX_STATE_PATH)
128
129
 
130
+ # Timer
129
131
  t_fox.stop
130
132
  t_exe = Timer.new " Execute SQL"
131
133
 
@@ -31,9 +31,12 @@ module Prick
31
31
  # Pool of nodes. Initialized by #load_pool
32
32
  attr_reader :pool
33
33
 
34
- forward_to :pool, :nodes, :decl_nodes, :init_nodes, :term_nodes,
34
+ forward_to :pool, :schemas,
35
+ :nodes, :decl_nodes, :init_nodes, :term_nodes,
35
36
  :seed_nodes, :fox_seed_nodes, :sql_seed_nodes,
36
- :schemas
37
+ :builder_nodes,
38
+ :pg_graph_ignore_schemas,
39
+ :refresh_schemas, :keep_schemas
37
40
 
38
41
  def batches() @batches ||= group end
39
42
 
@@ -44,6 +47,7 @@ module Prick
44
47
  @clean = clean
45
48
  @pool = NodePool.new
46
49
  @root = Parser.parse(conn, dir)
50
+ @pg_graph_ignore_schemas = []
47
51
  load_pool(@root) # Collect nodes into pool
48
52
  @batches = nil # Initialized by #group
49
53
  end
@@ -90,6 +94,7 @@ module Prick
90
94
  def execute(conn, create_schemas: schemas)
91
95
  group if batches.nil?
92
96
  conn.exec create_schemas.grep_v("public").map { |schema| "create schema #{schema}" }
97
+ conn.schema.create("public", authorization: "postgres")
93
98
  for batch in batches
94
99
  batch.execute
95
100
  end
data/lib/builder/node.rb CHANGED
@@ -142,6 +142,7 @@ module Prick
142
142
  end
143
143
  end
144
144
 
145
+ # A build.yml file node
145
146
  class BuildNode < Node
146
147
  def nodes() @nodes ||= init_nodes + decl_nodes + seed_nodes + term_nodes end
147
148
 
@@ -150,12 +151,17 @@ module Prick
150
151
  attr_reader :term_nodes
151
152
  attr_reader :seed_nodes
152
153
 
154
+ attr_accessor :pg_graph_ignore_schema
155
+ attr_accessor :refresh_schema
156
+
153
157
  def initialize(parent, path)
154
158
  super(parent, nil, :yml, path)
155
159
  @decl_nodes = []
156
160
  @init_nodes = []
157
161
  @term_nodes = []
158
162
  @seed_nodes = []
163
+ @pg_graph_ignore_schema = false
164
+ @refresh_schema = true
159
165
  end
160
166
 
161
167
  def inspect() to_s end
@@ -164,6 +170,7 @@ module Prick
164
170
  puts "BuildNode #{path}"
165
171
  indent {
166
172
  puts "schema: #{schema}" if schema
173
+ puts "pg_graph_ignore_schema: #{pg_graph_ignore_schema}"
167
174
  decl_nodes.each(&:dump)
168
175
  for kind in [:init, :term, :seed]
169
176
  kind_nodes = self.send("#{kind}_nodes".to_sym)
@@ -18,6 +18,24 @@ module Prick
18
18
  def fox_seed_nodes() seed_nodes.select { |node| node.kind == :fox } end
19
19
  def sql_seed_nodes() seed_nodes.select { |node| node.kind == :sql } end
20
20
 
21
+ # List of BuildNode nodes
22
+ def build_nodes() nodes.select { |node| node.is_a?(BuildNode) } end
23
+
24
+ # List of schemas to ignore when building PgGraph objects. This is used
25
+ # to exclude foreign schemes that doesn't follow the PgGraph naming
26
+ # conventions
27
+ def pg_graph_ignore_schemas()
28
+ build_nodes.select(&:pg_graph_ignore_schema).map(&:schema).uniq
29
+ end
30
+
31
+ def refresh_schemas()
32
+ build_nodes.select(&:refresh_schema).map(&:schema).uniq
33
+ end
34
+
35
+ def keep_schemas()
36
+ build_nodes.reject(&:refresh_schema).map(&:schema).uniq
37
+ end
38
+
21
39
  def initialize()
22
40
  self.clear
23
41
  end
@@ -50,7 +50,10 @@ module Prick
50
50
  entry.each { |key, value|
51
51
  if key == "schema"
52
52
  unit.schema = value
53
- # @schemas[unit.schema = value] = true
53
+ elsif key == "standard"
54
+ unit.pg_graph_ignore_schema = !value
55
+ elsif key == "refresh"
56
+ unit.refresh_schema = value
54
57
  else
55
58
  case key
56
59
  when "init"; unit.init_nodes
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.10"
4
+ VERSION = "0.20.13"
5
5
  end
@@ -8,19 +8,38 @@ module Prick::SubCommand
8
8
  time "Prick::Command#build" do
9
9
  begin
10
10
  super_conn = PgConn.new
11
+
11
12
  conn = nil
12
13
  builder = nil
13
-
14
14
  time "Load build object" do
15
15
  if super_conn.rdbms.exist? database
16
16
  conn = PgConn.new(database, username)
17
- super_conn.rdbms.empty!(database)
17
+ exist = true
18
18
  else
19
19
  super_conn.rdbms.create database, owner: username
20
20
  conn = PgConn.new(database, username)
21
+ exit = false
21
22
  end
22
23
 
23
24
  builder = Prick::Build::Builder.new(conn, builddir)
25
+
26
+ if exist
27
+ # Explicit schema is always rebuilt
28
+ refresh = [builder.refresh_schemas, schema].compact.flatten.uniq
29
+ keep = builder.keep_schemas.reject { |s| s == schema }
30
+
31
+ # Rebuild non-existing keep-schemas
32
+ keep.reject! { |schema|
33
+ refresh << schema if !conn.schema.exist?(schema)
34
+ }
35
+
36
+ # Eliminate keep schemas from build pool
37
+ builder.pool.delete_schema(keep)
38
+
39
+ # Drop refresh schemes
40
+ refresh.each { |schema| conn.schema.drop(schema, cascade: true) }
41
+ end
42
+
24
43
  builder.pool.delete_schema(builder.pool.after_schema(schema)) if schema
25
44
  end
26
45
 
data/prick.gemspec CHANGED
@@ -34,9 +34,9 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency "constrain"
35
35
  spec.add_dependency "forward_to"
36
36
  spec.add_dependency "bootsnap"
37
- spec.add_dependency "fixture_fox" "~> 0.1.3"
37
+ spec.add_dependency "fixture_fox", "~> 0.1.3"
38
38
  spec.add_dependency "postspec"
39
- spec.add_dependency "pg_graph"
39
+ spec.add_dependency "pg_graph", "~> 0.1.8"
40
40
  spec.add_dependency "shellopts", "~> 2.0.23"
41
41
 
42
42
  spec.add_development_dependency "ruby-prof"
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.20.10
4
+ version: 0.20.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-04 00:00:00.000000000 Z
11
+ date: 2022-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic
@@ -81,19 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: fixture_fox~> 0.1.3
84
+ name: fixture_fox
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 0.1.3
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 0.1.3
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: postspec
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: pg_graph
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 0.1.8
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 0.1.8
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: shellopts
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  - !ruby/object:Gem::Version
231
231
  version: '0'
232
232
  requirements: []
233
- rubygems_version: 3.3.12
233
+ rubygems_version: 3.1.4
234
234
  signing_key:
235
235
  specification_version: 4
236
236
  summary: A release control and management system for postgresql