postspec 0.2.1 → 0.2.3
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 +8 -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: ac68d61de369fe3aced2e4b6a2dfebc1e9d293c879854f3e094755357bde7a63
|
4
|
+
data.tar.gz: d0bb3d0e90935bd47d080aee31572a3a04b91937de6d4879ce2e3150754d3a0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f42c180b14d7574c8f85223a1b50d7169b05a2a459cf44ba739e7d1cea4f320d17b983800e20acb995ea6dd21220490f97e36e732bba72371689e964c0b8e067
|
7
|
+
data.tar.gz: 21226245ef6d07cd076585b550ac2f5d820d82372430415934b63ad97f83a7f010e45243190b6172bc75831dd5c8b2ed836ed15feaec96a7e9230bb9a71249cc
|
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,7 @@ module Postspec
|
|
59
63
|
# puts "Environment#clean"
|
60
64
|
@uids = {}
|
61
65
|
user_tables = dirty_tables
|
66
|
+
|
62
67
|
postspec_tables = CHANGE_TABLE_UIDS
|
63
68
|
sql = render.delete_tables(user_tables) +
|
64
69
|
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.3
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-inflector
|