deckard 0.4.1 → 0.6.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +26 -30
- data/lib/deckard/cli.rb +15 -11
- data/lib/deckard/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0061b5bce8bdbfb3f3787dc5049ed35504081529c2bd8aa796526467fdffea35
|
|
4
|
+
data.tar.gz: 714d6d18d26ab344bcadc8f4a284a403b3169260f96b100897ece7b04f9a02f4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33a6db2baa60c146f463c00151034bf4c4de3a970033d9e27d921b42b55fef2b1e1f25c52b91a17643edfe6643e153d6623c86e931960ab04a1c05f8de5f311b
|
|
7
|
+
data.tar.gz: 3aa42e22d2618ff664b9fc83ea3e0a7babda68ac57be546b6b638bbfdca9fb453f03b359726c3498ecea9be7782ccca18ffad4915cba4fe12b268d3a25472745
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ change the stream format and the Ruby API.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.0] - 2026-11-19
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Dump, load, and plan commands now boot automatically from a Rails app root
|
|
15
|
+
when `config/environment.rb` is present. See [application boot](docs/spec.md#62-requiring-the-application-environment).
|
|
16
|
+
|
|
10
17
|
## [0.4.1] - 2026-11-17
|
|
11
18
|
|
|
12
19
|
### Changed
|
data/README.md
CHANGED
|
@@ -12,7 +12,7 @@ for ActiveRecord 8 and PostgreSQL.
|
|
|
12
12
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
15
|
-
Add the gem to both applications:
|
|
15
|
+
Add the gem to both applications and run `bundle install` in each:
|
|
16
16
|
|
|
17
17
|
```ruby
|
|
18
18
|
gem "deckard"
|
|
@@ -41,12 +41,13 @@ class Order < ActiveRecord::Base
|
|
|
41
41
|
end
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
From your
|
|
45
|
-
one pipe.
|
|
44
|
+
From your local Rails app root, dump on the remote side and load locally in
|
|
45
|
+
one pipe. Deckard loads `config/environment.rb` from each app's working
|
|
46
|
+
directory when present.
|
|
46
47
|
|
|
47
48
|
```bash
|
|
48
|
-
ssh prod.example.org
|
|
49
|
-
|
|
|
49
|
+
ssh prod.example.org 'cd /app && bundle exec deckard --dump "Order.find(1234)"' \
|
|
50
|
+
| bundle exec deckard --load
|
|
50
51
|
```
|
|
51
52
|
|
|
52
53
|
Standard error on each end reports what moved:
|
|
@@ -66,10 +67,13 @@ rather than duplicated. Everything else is a new row with a new id.
|
|
|
66
67
|
To keep a dump around, write it to a file and load it later:
|
|
67
68
|
|
|
68
69
|
```bash
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
bundle exec deckard --dump 'Order.find(1234)' > order.dump
|
|
71
|
+
bundle exec deckard --load < order.dump
|
|
71
72
|
```
|
|
72
73
|
|
|
74
|
+
Use `-r FILE` when you need to override automatic boot. See
|
|
75
|
+
[application boot](docs/spec.md#62-requiring-the-application-environment).
|
|
76
|
+
|
|
73
77
|
## What a dump carries
|
|
74
78
|
|
|
75
79
|
Dumping a record includes the rows it depends on (`belongs_to`), the record
|
|
@@ -131,8 +135,8 @@ before any record is dumped. Loading consults no plan at all.
|
|
|
131
135
|
To see a plan before pointing it at production, print it:
|
|
132
136
|
|
|
133
137
|
```bash
|
|
134
|
-
|
|
135
|
-
|
|
138
|
+
bundle exec deckard --plan Order
|
|
139
|
+
bundle exec deckard --plan Order --format json
|
|
136
140
|
```
|
|
137
141
|
|
|
138
142
|
```text
|
|
@@ -149,12 +153,9 @@ Customer
|
|
|
149
153
|
|
|
150
154
|
## Dumping
|
|
151
155
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
stray `puts` in an initializer) cannot corrupt it: before requiring the
|
|
156
|
-
application, deckard keeps the original stdout for itself and points file
|
|
157
|
-
descriptor 1 at stderr.
|
|
156
|
+
`--dump` evaluates a Ruby expression and streams the result to standard
|
|
157
|
+
output. Deckard sends diagnostics and app boot output to standard error.
|
|
158
|
+
See [application output during a dump](docs/spec.md#66-application-output-during-a-dump).
|
|
158
159
|
|
|
159
160
|
For more involved selection, pass a Ruby file instead of an expression. The
|
|
160
161
|
script runs in a context exposing `dump(object)`:
|
|
@@ -167,19 +168,19 @@ dump repo.issues
|
|
|
167
168
|
```
|
|
168
169
|
|
|
169
170
|
```bash
|
|
170
|
-
|
|
171
|
+
bundle exec deckard --dump config/deckard/dump-repo.rb tilt > repos.dump
|
|
171
172
|
```
|
|
172
173
|
|
|
173
|
-
Extra command-line arguments reach the script through `ARGV`, and
|
|
174
|
-
reads the script from standard input. An expression given to
|
|
174
|
+
Extra command-line arguments reach the script through `ARGV`, and `--dump -`
|
|
175
|
+
reads the script from standard input. An expression given to `--dump` runs in
|
|
175
176
|
the same context, so it may call `dump` directly. While stderr is a
|
|
176
177
|
terminal, a live object counter shows progress on both ends of the pipe.
|
|
177
178
|
|
|
178
179
|
## Loading
|
|
179
180
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
`--load` reads a stream from standard input and loads it in one transaction.
|
|
182
|
+
The load bypasses model validations and callbacks. If the source dies
|
|
183
|
+
mid-stream, nothing is committed.
|
|
183
184
|
|
|
184
185
|
Deckard syncs a primary key that is not auto-populated like any other
|
|
185
186
|
field. Give that model a match key if the same dump will be loaded twice.
|
|
@@ -209,13 +210,8 @@ between two docker compose containers. `bundle exec rake test-all` runs both
|
|
|
209
210
|
host-side checks and the full-stack test. See `docs/spec.md` for the v1.0
|
|
210
211
|
specification and `docs/traversal.md` for how a dump walks the graph.
|
|
211
212
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
[`.crow/ruby.yaml`](.crow/ruby.yaml) defines the runtime versions and covers
|
|
215
|
-
specs, Standard lint, and the style ratchet. [`.crow/e2e.yaml`](.crow/e2e.yaml)
|
|
216
|
-
runs the end-to-end stream test. The performance suite remains a separate
|
|
217
|
-
local task.
|
|
213
|
+
See the [CI and validation guide](CLAUDE.md#ci-and-validation) for workflow
|
|
214
|
+
coverage and commands.
|
|
218
215
|
|
|
219
|
-
See
|
|
220
|
-
|
|
221
|
-
the files to update in a release PR.
|
|
216
|
+
See [Releasing Deckard](docs/releasing.md) for release setup and the files to
|
|
217
|
+
update in a release PR.
|
data/lib/deckard/cli.rb
CHANGED
|
@@ -5,10 +5,10 @@ require_relative "plan_report"
|
|
|
5
5
|
require_relative "status"
|
|
6
6
|
|
|
7
7
|
module Deckard
|
|
8
|
-
# The deckard executable:
|
|
9
|
-
# dumps a Ruby expression or dump script to
|
|
10
|
-
# from stdin, --plan prints a root model's plan.
|
|
11
|
-
# exe/deckard, not from the library itself.
|
|
8
|
+
# The deckard executable: boots the application in the working directory
|
|
9
|
+
# (or the file given to -r), -d dumps a Ruby expression or dump script to
|
|
10
|
+
# stdout, -l loads a stream from stdin, --plan prints a root model's plan.
|
|
11
|
+
# Required from exe/deckard, not from the library itself.
|
|
12
12
|
class CLI
|
|
13
13
|
# Evaluation context for dump scripts and -d expressions: exposes only
|
|
14
14
|
# dump(object). Scripts see any extra command-line arguments in ARGV.
|
|
@@ -31,7 +31,9 @@ module Deckard
|
|
|
31
31
|
def run(argv)
|
|
32
32
|
options = parse(argv)
|
|
33
33
|
reserve_stdout if options[:dump]
|
|
34
|
-
|
|
34
|
+
environment = options[:require]
|
|
35
|
+
environment ||= "config/environment.rb" if File.file?("config/environment.rb")
|
|
36
|
+
require File.expand_path(environment) if environment
|
|
35
37
|
|
|
36
38
|
if options[:dump]
|
|
37
39
|
dump(options[:dump])
|
|
@@ -69,15 +71,17 @@ module Deckard
|
|
|
69
71
|
banner <<~BANNER
|
|
70
72
|
deckard: stream ActiveRecord objects between Rails environments
|
|
71
73
|
|
|
72
|
-
dump: deckard
|
|
73
|
-
load: deckard
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
dump: deckard --dump "User.find(1)" > user.dump
|
|
75
|
+
load: deckard --load < user.dump
|
|
76
|
+
plan: deckard --plan User
|
|
77
|
+
|
|
78
|
+
Dump, load, and plan commands load config/environment.rb from the
|
|
79
|
+
current directory when present.
|
|
76
80
|
|
|
77
81
|
Options:
|
|
78
82
|
BANNER
|
|
79
|
-
opt :require, "Ruby file to
|
|
80
|
-
opt :dump, "Dump the result of a Ruby expression
|
|
83
|
+
opt :require, "Ruby file to load in place of config/environment.rb", type: :string
|
|
84
|
+
opt :dump, "Dump the result of a Ruby expression or run a dump script. Use - to read the script from standard input.", type: :string
|
|
81
85
|
opt :load, "Load a deckard stream from standard input"
|
|
82
86
|
opt :plan, "Print the plan for dumps rooted at MODEL", type: :string
|
|
83
87
|
opt :format, "Plan output: #{PlanReport::FORMATS.join(" or ")}", default: "text"
|
data/lib/deckard/version.rb
CHANGED