prick 0.39.12 → 0.39.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO +2 -1
- data/exe/prick +35 -15
- data/lib/prick/builder/batch.rb +7 -3
- data/lib/prick/builder/builder.rb +1 -1
- data/lib/prick/state.rb +10 -2
- data/lib/prick/subcommand/prick-fox.rb +10 -2
- data/lib/prick/subcommand/prick-init.rb +1 -1
- data/lib/prick/subcommand/prick-snapshot.rb +8 -1
- data/lib/prick/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: 7e4a3abb3d16add6ac8a34d01cf1b4f8c47db59b97110d5a53f7c137d7fac786
|
4
|
+
data.tar.gz: 197a7fed189ac1ace4fb185d17287aa397ab207c4b6c4def6e929341968ea5f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fabd3040287e7db1deace3ec62929eac32535a2182963fcf1842c868f56e8b25d3e0fbd8c0d93cfd6f1bfd7eaa970c9a3532c89aec3ae90611b703b677c5738f
|
7
|
+
data.tar.gz: 1a0dda8115fcd8f0d2aa100257782f50e7e2f2bd04c9fca7d20d64900e59623faf7a3f607ccd2c3b79bdfab50d1d9f251dc4abc770bef42523d82a626d88e980
|
data/TODO
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
o Make references to file stable when using -C
|
1
2
|
o prefix sql scripts with 'set ON_ERROR_STOP on'
|
2
3
|
o make it possible to build only one scheme
|
3
4
|
o cleanup connection
|
@@ -11,7 +12,7 @@ o Have the following entries
|
|
11
12
|
sql: SQL_STATEMENT
|
12
13
|
exec: BASH_COMMAND
|
13
14
|
eval: BASH_COMMAND
|
14
|
-
call:
|
15
|
+
call:
|
15
16
|
...
|
16
17
|
|
17
18
|
|
data/exe/prick
CHANGED
@@ -37,9 +37,15 @@ SPEC = %(
|
|
37
37
|
-e,environment-file=ENVIRONMENT-FILE
|
38
38
|
Override the environment file. Default is 'prick.environment.yml'
|
39
39
|
|
40
|
+
-r,reflections-file=REFLECTIONS-FILE
|
41
|
+
Override the reflections file. Default is 'schema/reflections.yml'
|
42
|
+
|
40
43
|
-s,state-file=STATE-FILE
|
41
44
|
Override state file. Default is '.prick-state.yml'
|
42
45
|
|
46
|
+
-f,fox-state-file=FOX-STATE-FILE
|
47
|
+
Override fox state file. Default is '.fox-state.yml
|
48
|
+
|
43
49
|
init! -n,name=NAME -t,title=TITLE DIRECTORY #@ Initialize new Prick project directory
|
44
50
|
Initializes a prick project and checks it into git. If a directory is
|
45
51
|
given the directory will be created and the project initialized in it.
|
@@ -117,7 +123,9 @@ SPEC = %(
|
|
117
123
|
drop.data!
|
118
124
|
@ Drop data
|
119
125
|
|
120
|
-
|
126
|
+
Drop data added to the database after the last snapshot was taken. It is
|
127
|
+
useful to run 'prick snapshot' immediately after you complete building
|
128
|
+
the database
|
121
129
|
|
122
130
|
build! --step -f,force -t,time --dump=KIND? -- [SCHEMA]
|
123
131
|
Build the project. If SCHEMA is defined, later schemas are excluded. KIND
|
@@ -134,12 +142,15 @@ SPEC = %(
|
|
134
142
|
run! --step -t,time --dump=KIND? --schema=SCHEMA -- PATH
|
135
143
|
@ Execute path in Prick environment
|
136
144
|
|
137
|
-
Execute a single directory or file within the Prick environment. If
|
138
|
-
a directory argument, the directory is searched for a build.yml
|
139
|
-
given a file argument, the file should be a .sql, .fox, or build
|
145
|
+
Execute a single build directory or file within the Prick environment. If
|
146
|
+
given a directory argument, the directory is searched for a build.yml
|
147
|
+
file. If given a file argument, the file should be a .sql, .fox, or build
|
148
|
+
file
|
140
149
|
|
141
150
|
The --schema option sets the current schema before executing the PATH
|
142
151
|
|
152
|
+
TODO: Allow executables
|
153
|
+
|
143
154
|
touch! -- [SUCCESS]
|
144
155
|
Record a build. SUCCESS can be 'true' (default) or 'false'. 'touch' is
|
145
156
|
used by external build processes that doesn't involve prick
|
@@ -148,18 +159,19 @@ SPEC = %(
|
|
148
159
|
Emit a bash script to build the database. The script is constructed from
|
149
160
|
the build attributes in the environment file
|
150
161
|
|
151
|
-
fox! -- FILE...
|
152
|
-
Load fox file data.
|
153
|
-
|
154
|
-
different data sets
|
162
|
+
fox! -r,reset +e,exclude=SCHEMA... -- FILE...
|
163
|
+
Load fox file data. Can be used together with 'prick snapshot' and 'prick
|
164
|
+
drop data' to to experiment with different data sets
|
155
165
|
|
156
|
-
|
157
|
-
|
166
|
+
The --reset option resets data to the last snapshot before loading the
|
167
|
+
file. The --exclude option lists schemas that should not be included in
|
168
|
+
fox, typically schemas that doens't comply with prick's naming
|
169
|
+
conventions
|
158
170
|
|
159
171
|
snapshot!
|
160
|
-
Records maximum ID for all tables and stores them in prick.snapshot
|
161
|
-
used by 'drop data' to reset data to the point in time of
|
162
|
-
Only one snapshot can be created at a time
|
172
|
+
Records maximum ID for all tables and stores them in the prick.snapshot
|
173
|
+
table. It is used by 'drop data' to reset data to the point in time of
|
174
|
+
the snapshot. Only one snapshot can be created at a time
|
163
175
|
|
164
176
|
reset!
|
165
177
|
Restore database to the last snapshot. TODO
|
@@ -240,6 +252,10 @@ def clean_pg_meta_cache
|
|
240
252
|
FileUtils.rm_f(PG_META_STATE_PATH)
|
241
253
|
end
|
242
254
|
|
255
|
+
def clean_fox_state
|
256
|
+
FileUtils.rm_f(Prick.state.fox_state_file)
|
257
|
+
end
|
258
|
+
|
243
259
|
def parse_database_args(state, args)
|
244
260
|
arg, environment = args.expect(0..2)
|
245
261
|
if arg
|
@@ -287,7 +303,9 @@ begin
|
|
287
303
|
# Handle -p, -e, and -c. TODO: Take -C into account for relative paths. Low-hanging fruit
|
288
304
|
project_file = opts.project_file || PRICK_PROJECT_PATH
|
289
305
|
environment_file = opts.environment_file || PRICK_ENVIRONMENT_PATH
|
306
|
+
reflections_file = opts.reflections_file || REFLECTIONS_PATH
|
290
307
|
state_file = opts.state_file || PRICK_STATE_PATH
|
308
|
+
fox_state_file = opts.fox_state_file || FOX_STATE_PATH
|
291
309
|
|
292
310
|
# Process init command and exit
|
293
311
|
if opts.subcommand == :init!
|
@@ -307,7 +325,7 @@ begin
|
|
307
325
|
end
|
308
326
|
|
309
327
|
# Load state
|
310
|
-
state = Prick.state = State.new(project_file, environment_file, state_file)
|
328
|
+
state = Prick.state = State.new(project_file, environment_file, reflections_file, state_file, fox_state_file)
|
311
329
|
|
312
330
|
# Lazyness
|
313
331
|
database = state.database
|
@@ -381,6 +399,7 @@ begin
|
|
381
399
|
when :build!
|
382
400
|
require_db
|
383
401
|
clean_pg_meta_cache
|
402
|
+
clean_fox_state
|
384
403
|
dump = cmd.dump? ? cmd.dump("batches")&.to_sym || :batches : nil
|
385
404
|
# exclude = cmd.exclude? ? cmd.exclude.split(",") : []
|
386
405
|
Prick::SubCommand.build(
|
@@ -390,6 +409,7 @@ begin
|
|
390
409
|
when :make!
|
391
410
|
require_db
|
392
411
|
clean_pg_meta_cache
|
412
|
+
clean_fox_state
|
393
413
|
dump = cmd.dump? ? cmd.dump("batches")&.to_sym || :batches : nil
|
394
414
|
Prick::SubCommand.make(
|
395
415
|
database, username, args.expect(0..1),
|
@@ -415,7 +435,7 @@ begin
|
|
415
435
|
|
416
436
|
when :fox!
|
417
437
|
require_db
|
418
|
-
Prick::SubCommand.fox(database, username, args)
|
438
|
+
Prick::SubCommand.fox(database, username, args, reset: cmd.reset?, exclude: cmd.exclude)
|
419
439
|
|
420
440
|
when :snapshot!
|
421
441
|
require_db
|
data/lib/prick/builder/batch.rb
CHANGED
@@ -122,8 +122,12 @@ module Prick
|
|
122
122
|
t_type.stop
|
123
123
|
t_fox = Timer.new " Parse files"
|
124
124
|
|
125
|
+
# Fetch state
|
126
|
+
ids, anchors = FixtureFox::Fox.read_state(type, Prick.state.fox_state_file)
|
127
|
+
|
125
128
|
# Create fox object
|
126
|
-
|
129
|
+
#
|
130
|
+
fox = FixtureFox::Fox.new(type, ids: ids, anchors: anchors)
|
127
131
|
|
128
132
|
# Parse files
|
129
133
|
for file in files
|
@@ -135,8 +139,8 @@ module Prick
|
|
135
139
|
fox.assign_types
|
136
140
|
fox.generate
|
137
141
|
|
138
|
-
# Dump state file
|
139
|
-
fox.write_state(
|
142
|
+
# Dump new state file
|
143
|
+
fox.write_state(Prick.state.fox_state_file)
|
140
144
|
|
141
145
|
# Timer
|
142
146
|
t_fox.stop
|
data/lib/prick/state.rb
CHANGED
@@ -24,9 +24,16 @@ module Prick
|
|
24
24
|
# absent if the project doesn't use environments
|
25
25
|
attr_reader :environment_file
|
26
26
|
|
27
|
+
# Reflections file. Default 'schema/reflections.yml'. May be nil if the
|
28
|
+
# file is absent
|
29
|
+
attr_reader :reflections_file
|
30
|
+
|
27
31
|
# State file. Default '.prick-state.yml'
|
28
32
|
attr_reader :state_file
|
29
33
|
|
34
|
+
# Fox state file. Default '.fox-state.yml'
|
35
|
+
attr_reader :fox_state_file
|
36
|
+
|
30
37
|
# Schema data file. FIXME What is this?
|
31
38
|
def schema_file() SCHEMA_VERSION_PATH end
|
32
39
|
|
@@ -95,8 +102,9 @@ module Prick
|
|
95
102
|
@clean = Git.clean?
|
96
103
|
end
|
97
104
|
|
98
|
-
def initialize(project_file, environment_file, state_file)
|
99
|
-
@project_file, @environment_file, @
|
105
|
+
def initialize(project_file, environment_file, reflections_file, state_file, fox_state_file)
|
106
|
+
@project_file, @environment_file, @reflections_file, @state_file, @fox_state_file =
|
107
|
+
project_file, environment_file, reflections_file, state_file, fox_state_file
|
100
108
|
@project_loaded = @state_loaded = @environment_loaded = false
|
101
109
|
|
102
110
|
if @project_file && File.exist?(@project_file)
|
@@ -3,8 +3,16 @@
|
|
3
3
|
require_relative '../builder/builder.rb'
|
4
4
|
|
5
5
|
module Prick::SubCommand
|
6
|
-
def self.fox(database, username, files)
|
7
|
-
|
6
|
+
def self.fox(database, username, files, reset: false, exclude: nil)
|
7
|
+
self.drop_data(database) # In prick-drop
|
8
|
+
opts = {
|
9
|
+
state: FOX_STATE_PATH,
|
10
|
+
delete: "none",
|
11
|
+
exec: true,
|
12
|
+
exclude: (exclude ? exclude.join(',') : nil),
|
13
|
+
reflections: Prick.state.reflections_file
|
14
|
+
}.reject { |k,v| v.nil? }.map { |k,v| "--#{k}#{v == true ? "" : "=#{v}"}" }.join(" ")
|
15
|
+
Command.command "fox #{opts} #{database} #{files.join(" ")}"
|
8
16
|
end
|
9
17
|
end
|
10
18
|
|
@@ -31,7 +31,7 @@ module Prick::SubCommand
|
|
31
31
|
Command.status == 0 or Prick.failure "Failed creating initial import"
|
32
32
|
|
33
33
|
# Write (valid) configuration file
|
34
|
-
state = State.new(project_file, nil, nil)
|
34
|
+
state = State.new(project_file, nil, nil, nil, nil)
|
35
35
|
state.name = name
|
36
36
|
state.title = title
|
37
37
|
state.prick_version = PrickVersion.new VERSION
|
@@ -4,7 +4,7 @@ require_relative '../builder/builder.rb'
|
|
4
4
|
|
5
5
|
module Prick::SubCommand
|
6
6
|
def self.snapshot(
|
7
|
-
database, username,
|
7
|
+
database, username,
|
8
8
|
builddir: Prick.state.schema_dir)
|
9
9
|
|
10
10
|
conn = Prick.state.connection
|
@@ -24,6 +24,13 @@ module Prick::SubCommand
|
|
24
24
|
}
|
25
25
|
end
|
26
26
|
conn.insert("prick", "snapshots", records)
|
27
|
+
|
28
|
+
# Patch fox state file
|
29
|
+
state = YAML.load(IO.read(Prick.state.fox_state_file))
|
30
|
+
for record in records
|
31
|
+
state[:ids][record[:schema_name] + '.' + record[:table_name]] = record[:max_id] if record[:max_id]
|
32
|
+
end
|
33
|
+
IO.write(Prick.state.fox_state_file, YAML.dump(state))
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
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.39.
|
4
|
+
version: 0.39.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: 2024-09-
|
11
|
+
date: 2024-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semantic
|