postspec 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/postspec/environment.rb +10 -3
- data/lib/postspec/render.rb +1 -1
- data/lib/postspec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7a02e5c14b838e05beeedf3ddd025b33b504ce0846d087680a2eb9dda993a97
|
4
|
+
data.tar.gz: 1870c61f2595c33c6ea2453cdf1f56fea06fb3433ca390eb78e79f090a0a84d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a4a823ba661cc886208c72a7e92486ad8b836c5502acbd6bc0fe8a477f201490f5a1fb3433644e4ec296089b2d35d55d4fc35dfbe46ce4029f779924c2b603d
|
7
|
+
data.tar.gz: ae0b0c54259a9ddcdd29bda1a7cc6eba57aa2810eb6d0b23146d15afc05afeaf3306fda0d07e8db8fa5b84d93d702f0af40403f32071f4601def861fd6f56c12
|
data/lib/postspec/environment.rb
CHANGED
@@ -21,16 +21,20 @@ module Postspec
|
|
21
21
|
conn.map "select table_uid, record_id from postspec.seeds"
|
22
22
|
end
|
23
23
|
|
24
|
+
# Returns an array from table name to maximum ID used in the table or in
|
25
|
+
# the root table if this is a subtable
|
24
26
|
def table_max_ids
|
25
27
|
result = table_sequence_ids(all: true)
|
26
|
-
postspec.type.tables.select(&:
|
27
|
-
result[table.uid] = result[table.
|
28
|
+
postspec.type.tables.select(&:sub_table?).each { |table|
|
29
|
+
result[table.uid] = result[table.root_table.uid] or raise "Oops: #{table.uid}"
|
28
30
|
}
|
29
31
|
result
|
30
32
|
end
|
31
33
|
|
32
34
|
# Returns map from table UID to record ID of the last record to be kept so
|
33
|
-
# that 'delete from table_uid where id > record_id' does the right thing
|
35
|
+
# that 'delete from table_uid where id is null or id > record_id' does the right thing
|
36
|
+
#
|
37
|
+
#
|
34
38
|
# Note: This assumes that the change triggers has been installed beforehand
|
35
39
|
def dirty_tables
|
36
40
|
seed_ids = table_seed_ids
|
@@ -59,6 +63,9 @@ module Postspec
|
|
59
63
|
# puts "Environment#clean"
|
60
64
|
@uids = {}
|
61
65
|
user_tables = dirty_tables
|
66
|
+
$stderr.puts "user_table: #{user_tables.inspect}"
|
67
|
+
$stderr.puts " #{user_tables.select { |k,v| v.nil? }.inspect}"
|
68
|
+
|
62
69
|
postspec_tables = CHANGE_TABLE_UIDS
|
63
70
|
sql = render.delete_tables(user_tables) +
|
64
71
|
render.delete_tables(postspec_tables)
|
data/lib/postspec/render.rb
CHANGED
@@ -104,7 +104,7 @@ module Postspec
|
|
104
104
|
sql =
|
105
105
|
uids.map { |uid, id| "delete from #{uid}" + (id > 0 ? " where id > #{id}" : "") } +
|
106
106
|
uids.select { |uid|
|
107
|
-
uid =~ /^postspec\./ ? true : !postspec.type.dot(uid).
|
107
|
+
uid =~ /^postspec\./ ? true : !postspec.type.dot(uid).sub_table?
|
108
108
|
}.map { |uid, id|
|
109
109
|
"alter table #{uid} alter column id restart" + (id > 0 ? " with #{id+1}" : "")
|
110
110
|
}
|
data/lib/postspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-inflector
|