trellis-pg 0.3.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b9aabe1cb44b52da084051347386cd0bfbeafaae2bc78fa8542ec89b06fcb60
4
- data.tar.gz: 718bad6383958ae472881b82de1007acce1e037e62360e7c69200878cf24d981
3
+ metadata.gz: cd96adac04baff92684e23cb1b8c537009c3f5600635c2d061dc7bb06e219d91
4
+ data.tar.gz: 3fd455be94102ca285e4e094f6a32f36daba286066ddcc9c7e89c6262154557e
5
5
  SHA512:
6
- metadata.gz: 5872bb56236709d58964ceecb63c713b1a71485efe0778cb9d50fe571230e8ccfa5117d664333aacf474b1d91a3b48d04e2b5e483798058b488eac1687d8e6f6
7
- data.tar.gz: 6b6af1033f671c05a44b91d5cbdd738a643816f3dafc3bd59cc29d571b69bff46a06b2929834ac33838306388d20d65f6d7890fc343578d2590782360c0e4ad5
6
+ metadata.gz: 4df55ebf64316e75919cd2787b32204551b410d158e1fa0e41eb3afbaffda614e0ea138fc836b9cba2a2586db8a4556f787e3e97089b906cce49f5f84f02fa49
7
+ data.tar.gz: 180ee5359ead7aca7155ca3c5a526dd8d41020c4f4873f0c1335ee115c1d626e4e0f5dabe3b20dc30a95f47df2ab29f188dc2e772995ed521ae541959b9b55d5
data/README.md CHANGED
@@ -18,7 +18,7 @@ as `trellis/pg`. The module is still `Trellis`.
18
18
 
19
19
  ```ruby
20
20
  # Gemfile
21
- gem "trellis-pg", "~> 0.3.0"
21
+ gem "trellis-pg", "~> 0.4.0"
22
22
  ```
23
23
 
24
24
  `Bundler.require`, which a Rails app's `config/application.rb` runs,
@@ -60,58 +60,19 @@ Nothing in the binding uses it.
60
60
  (`:transform_defined`, `:paused`, `:resumed`, ...).
61
61
  `Trellis.define(statement)` is an `apply` that refuses anything but a
62
62
  `TRANSFORM`, and returns its fully qualified target table.
63
- - `Trellis.status(target_table)`, `Trellis.definitions`: the catalog reads
64
- (each status word and field: the
65
- [status reference](../../docs/status-reference.md)).
63
+ - `Trellis.status(target_table)`, `Trellis.definitions`: the catalog reads.
64
+ `status` returns a `Trellis::Status` (with nested `Trellis::DrainFailure`,
65
+ `Trellis::SourceIndexGap`, `Trellis::ExtremeIndexGap`,
66
+ `Trellis::CorrectingNode`, `Trellis::VersionHandover`,
67
+ `Trellis::BelowCatalogFloor`, `Trellis::RefusedStep`, `Trellis::JoinStatus`
68
+ and the like) whose fields are named and defined in the
69
+ [status reference](../../docs/status-reference.md).
66
70
  - `Trellis.quarantined`, `Trellis.quarantine_status(target)`,
67
71
  `Trellis.sample_quarantined(target, limit:, after:)`,
68
72
  `Trellis.poisoned_since(time)`: the quarantine reads. Resuming is a
69
73
  statement: `Trellis.apply("RESUME TRANSFORM order_totals.total")`.
70
74
  `Trellis.release_key(transform, source_table, key)` releases one key a
71
- transform holds, once its cause is fixed; `status` reports how many it
72
- holds (`held_keys`). `status` also reports a page the drain keeps failing
73
- on with nothing charged or paused (`drain_failure`, a
74
- `Trellis::DrainFailure`), and a finished `self_check` job's report lists
75
- every one open (`drain_failures`). `status` names the paused upstream columns
76
- (`paused_upstream_columns`, each `"target.column"`) that make a `live`
77
- definition report `catching_up`. `status` lists the source indexes a
78
- `GROUP BY` or `JOIN` target
79
- needs and lacks (`source_index_gaps`, each a `Trellis::SourceIndexGap` with
80
- `table`, `columns`, `role` (`:group_by`, `:join_from` or `:join_joined`: the part of
81
- the definition that needs it), `opted_out` and a `create index` statement as `fix`);
82
- `self_check` refuses such a target unless it was defined `WITHOUT SOURCE
83
- INDEX`. `status` lists the source indexes a `MIN`/`MAX` aggregate's probes
84
- read and the source lacks (`extreme_index_gaps`, each a
85
- `Trellis::ExtremeIndexGap` with `table`, `columns`, `argument`, `opted_out`
86
- and `fix`); nothing pauses, and a deleted extreme is re-read by scanning
87
- its group. `status` lists the partitions of a partitioned source a definition
88
- is being corrected for while it reads `:backfilling` for them
89
- (`correcting`, each a `Trellis::CorrectingNode` with `node`, `since` and
90
- `keys_remaining`). `status` names what a Re-derive build waits on instead
91
- of its own work (`build_wait_xid`, the transaction id of the fence it
92
- waits out, `nil` when it waits on nothing). While a process of another
93
- Trellis version is live, `status` reports that this process stands by
94
- (`version_handover`, a `Trellis::VersionHandover` with `this_version`,
95
- `processes`, each a `Trellis::OtherProcess` with `worker_id` and
96
- `version` (`nil` for a release before 0.2.0),
97
- `unregistered_staging_worker` and `migrations_pending`), and
98
- state-changing calls raise a `version_handover` error until it is gone.
99
- While this binary is below the catalog floor, `status` reports that this
100
- process stands by (`below_catalog_floor`, a `Trellis::BelowCatalogFloor`
101
- with `floor` and `this_version`), and state-changing calls raise a
102
- `version_floor` error.
103
- For a `JOIN` definition `status` reports its hidden tables (`join`, a
104
- `Trellis::JoinStatus`): `hidden_tables`, each a `Trellis::HiddenTable` with
105
- `table`, `name`, `estimated_rows` and `bytes`, the `P`-size warning
106
- (`partials_warning`, a `Trellis::PartialsWarning`), a 1-1 `JOIN`'s fan-out
107
- warnings (`fan_out_warnings`, one `Trellis::FanOutWarning` per joined
108
- position past the threshold, naming its `position`) and the step its build
109
- runs (`building`, a `Trellis::JoinBuildStep` with `step` and the `side`,
110
- `part`, `leaf`, `remaining` or `position` its kind of step carries). `join` is
111
- `nil` for any other definition. `status` reports the oldest Trellis release
112
- that can run a definition (`floor`, `"major.minor.patch"`), which an
113
- application reads before rolling back to an earlier Trellis release
114
- ([upgrading](../../docs/upgrading.md#rolling-back)).
75
+ transform holds, once its cause is fixed.
115
76
  - `Trellis.request_backfill(source_table)`,
116
77
  `Trellis.detect_capture_disruptions` (pauses now the readers of every table
117
78
  whose Trellis capture was changed outside Trellis, and returns the tables),
@@ -130,6 +91,9 @@ Nothing in the binding uses it.
130
91
  and `self_check_job` returns `nil` for the replaced job or one whose
131
92
  transform was dropped. With no drain worker anywhere in the fleet a job
132
93
  stays `:queued`.
94
+ - `Trellis.rollback(to:)`, `Trellis.uninstall` and their `_plan` variants,
95
+ which change nothing: leave this release (see
96
+ [Rolling back and uninstalling](#rolling-back-and-uninstalling)).
133
97
  - `Trellis::Metrics.render_prometheus`: the process-wide metrics registry as
134
98
  Prometheus text (the binding opens no port; `Trellis::Metrics::RackApp` is a
135
99
  mountable route and `Trellis::Metrics::Middleware` appends it to an
@@ -177,6 +141,7 @@ Trellis.shutdown
177
141
  | `worker_threads:` | `2` | the threads of each Rust runtime a handle owns (its calls', and its background client's), invisible to Ruby's own sizing |
178
142
  | `max_call_pool_size:` | `20` | the most connections the handle's call pool opens; the background pool is sized by `staging:` and `drain_threads:` |
179
143
  | `call_pool_wait_timeout_ms:` | `30_000` | how long a call waits for a free call-pool connection before a `ConnectivityError` |
144
+ | `claim_grace_period_ms:` | `600_000` | how long the owner version may be silent before a standing-by process of another version claims the instance ([sizing it](../../docs/embedding.md#configuration-from-the-environment)) |
180
145
 
181
146
  The defaults run nothing in the background. Some process in a fleet must set
182
147
  `staging: true` and some process must run drain threads, or no definition ever
@@ -367,7 +332,9 @@ default one included.
367
332
  `NotFoundError`, `InternalError`, `TimeoutError`, `VersionHandoverError`,
368
333
  `VersionFloorError`),
369
334
  each with `#code` (a
370
- symbol) and `#message`. A code newer than the binding arrives as
335
+ symbol), `#error_id` (the engine's per-error code, `"T0042"`, which the
336
+ message starts with; `nil` for an error the binding raises itself) and
337
+ `#message`. A code newer than the binding arrives as
371
338
  `UnknownError`, naming the code in its message. `ForkedHandleError` is a
372
339
  `ValidationError`. Raising is Ruby's idiom, so where the Elixir binding
373
340
  has `{:ok, value}` / `{:error, error}` and bang variants, every Ruby
@@ -402,18 +369,31 @@ include with a clear error on a Rails without the internals it guards (7.1).
402
369
  ### Configuration and boot
403
370
 
404
371
  The Rails integration reads `Trellis.connect`'s options from one place,
405
- `config.trellis.connect`:
372
+ `config.trellis.connect`. Trellis's definitions live in the database, so the
373
+ schema dump must be SQL; Rails's default `:ruby` makes `db:migrate` fail
374
+ ([Schema dumps](#schema-dumps)):
406
375
 
407
376
  ```ruby
408
377
  # config/application.rb (or config/environments/*.rb)
378
+ config.active_record.schema_format = :sql
409
379
  config.trellis.connect = {
410
- url: ENV.fetch("DATABASE_URL"),
380
+ # A direct or session-mode URL, not the app's pooled DATABASE_URL.
381
+ url: ENV.fetch("TRELLIS_DATABASE_URL"),
411
382
  # The one dedicated worker process sets TRELLIS_WORKER=1.
412
383
  staging: ENV["TRELLIS_WORKER"] == "1",
413
384
  drain_threads: ENV["TRELLIS_WORKER"] == "1" ? 2 : 0
414
385
  }
415
386
  ```
416
387
 
388
+ The dedicated worker is one extra process running your app with that variable,
389
+ for example this `Procfile` line:
390
+
391
+ ```
392
+ worker: TRELLIS_WORKER=1 bin/rails runner 'sleep'
393
+ ```
394
+
395
+ Connect directly or through a session-mode pooler, never a transaction-mode one ([recommendations](../../docs/recommendations.md#connect-directly-or-through-a-session-mode-pooler)).
396
+
417
397
  With it set, the app's default instance connects as the app boots (an
418
398
  `after_initialize` hook), and the `at_exit` hook shuts it down. Left `nil`,
419
399
  the default, the Railtie connects no default instance.
@@ -450,8 +430,8 @@ With neither set, the Railtie does nothing. Two exceptions:
450
430
  preloading Passenger, say). Connect in each child with
451
431
  `Trellis::Railtie.connect`.
452
432
 
453
- `config.trellis.off_in` turns all of this off in the environments it names
454
- (the `test` environment, by default): see [Testing](#testing).
433
+ `config.trellis.off_in` turns the boot connect off in the environments it
434
+ names (the `test` environment, by default): see [Testing](#testing).
455
435
 
456
436
  ### Logs in Rails
457
437
 
@@ -561,11 +541,39 @@ end
561
541
  app uses `structure.sql`.
562
542
 
563
543
  `rails trellis:migrate` creates or upgrades Trellis's own tables the same
564
- way. The helpers run it whenever a migration defines something, and a worker
565
- of a new gem version runs it by itself once the old version's processes have
566
- stopped. Run it in the deploy step as well (`bin/rails trellis:migrate
567
- db:migrate`) to create the tables on a fresh database, to upgrade them before
568
- the worker restarts, or when the worker's database role can't alter them.
544
+ way, for a deploy step that runs no database task. The helpers run it whenever
545
+ a migration defines something.
546
+
547
+ #### Rake task hooks
548
+
549
+ The instance belongs to the version that last ran `migrate`
550
+ ([Upgrading](../../docs/upgrading.md)), so the Rails tasks that move a
551
+ database between schema versions run Trellis's `migrate` after their own work,
552
+ whether or not a migration was pending: `db:migrate` (and `db:migrate:up`,
553
+ `:down`, `:redo`, `db:migrate:<name>`), `db:rollback[:<name>]`, `db:prepare`,
554
+ `db:schema:load[:<name>]`, `db:test:prepare` and `db:test:load_schema[:<name>]`.
555
+ A gem-only bump, with nothing pending, claims the instance too, and so does
556
+ `db:prepare`, which Kamal and the generated Dockerfile run at every boot.
557
+
558
+ - **Once per database per process,** for the `config.trellis.dump_database`
559
+ of each environment the task touches (`db:prepare` in development also does
560
+ the test database). A task on another database of a multi-database app does
561
+ nothing.
562
+ - **After the task succeeds.** A failing task runs no hook, and a failing
563
+ `migrate` fails the task.
564
+ - **In `off_in` environments too,** like the migration helpers.
565
+ - **Rake only.** `ActiveRecord::Tasks::DatabaseTasks.prepare_all` called from
566
+ `rails runner`, or any code that skips Rake, runs no hook: call
567
+ `Trellis::Railtie.migrate_all` there.
568
+ - **Off with** `config.trellis.task_hooks = false`. The schema load still
569
+ restores a dump's definitions ("Schema dumps").
570
+
571
+ Whether `migrate` runs at every container boot or as one deploy job is your
572
+ choice ([where `migrate` runs](../../docs/upgrading.md#where-migrate-runs)).
573
+ No hook covers Capistrano's
574
+ `conditionally_migrate` on a gem-only bump (it skips `db:migrate`), `helm
575
+ rollback` (it runs no pre-upgrade job) or a programmatic caller. A worker's
576
+ own claim is the backstop there.
569
577
 
570
578
  `Trellis::Railtie.with_handle { ... }` is what `trellis:migrate` and the
571
579
  helpers use, for a script or rake task of your own that needs Trellis the
@@ -578,6 +586,13 @@ instance and every instance of `config.trellis.instances`. Neither it nor
578
586
  Outside Rails, `require "trellis/migration"` and `Trellis.connect` before
579
587
  migrating.
580
588
 
589
+ `db:prepare` in development also migrates the test databases. A migration
590
+ of another environment's database, or of one where Trellis is off, never
591
+ uses a connected handle: the helpers and `with_handle` connect to that
592
+ environment's counterpart of the database the instance's `url` points at
593
+ (the `database.yml` config of the same name), or to the migrating database
594
+ when the `url` names none, with the instance's other options.
595
+
581
596
  ### Targets as models
582
597
 
583
598
  Only Trellis writes a target. Declare a model over one with
@@ -616,45 +631,27 @@ Account.find(42).event_counts.sum(:n) # with has_many :event_counts on Account
616
631
 
617
632
  ### Upgrading the gem
618
633
 
619
- A release that changes `trellis-pg`'s version can't also define, alter,
620
- pause, resume or drop a transform. While a worker of the old version runs,
621
- those statements refuse with `Trellis::VersionHandoverError`
622
- ([rolling deploys](../../docs/embedding.md#rolling-deploys)), so a deploy
623
- that migrates before the old worker stops fails at its first Trellis
624
- migration. Ship the version change by itself, and the migrations in the next
625
- release.
626
-
627
- `rails trellis:release_check` fails a build that combines the two:
628
-
629
- ```sh
630
- bin/rails trellis:release_check BASE=origin/main
631
- ```
634
+ [Upgrading](../../docs/upgrading.md) explains what a version change does to a
635
+ running instance and how to roll back. In a Rails app the migration tasks run
636
+ Trellis's `migrate` ("Rake task hooks"), so a deploy that runs `db:migrate`
637
+ or `db:prepare` upgrades the instance, with or without a Trellis migration.
632
638
 
633
- It compares the working tree with its merge base against `BASE`, and exits 1
634
- when `trellis-pg`'s version in the lockfile changed and a migration added
635
- since then mentions `Trellis`. It reads git and files only: it needs no
636
- database and doesn't initialize the app.
639
+ ### Rolling back and uninstalling
637
640
 
638
- - **On a pull request**, `BASE` is the branch it targets. The job needs the
639
- history back to the merge base, which a shallow clone lacks:
641
+ Both are destructive, run by the release being left with every Trellis
642
+ process stopped. Each prints what it drops and empties, then asks you to
643
+ type its name; with no terminal, `CONFIRM=yes` stands in for it.
640
644
 
641
- ```yaml
642
- - uses: actions/checkout@v4
643
- with:
644
- fetch-depth: 0
645
- # ... install Ruby and the app's gems ...
646
- - run: bin/rails trellis:release_check BASE=origin/${{ github.base_ref }}
647
- ```
648
- - **For a release of several merged pull requests**, `BASE` is the last
649
- deployed ref: a version change and a migration that merged separately
650
- still deploy together.
651
- - It reads `db/migrate` and each database's `migrations_paths`, and sees
652
- migrations only. A state-changing call from a script or a console is in no
653
- file it reads; the engine still refuses it.
645
+ - `bin/rails trellis:rollback [TO=0.3.1]` hands the database to an earlier
646
+ release, below the catalog floor included. Then deploy that release and
647
+ run its migrate; it rebuilds every target. Until then, a Rails task with
648
+ the newer gem that runs the [hooks](#rake-task-hooks) (`db:prepare` at a
649
+ container's boot, `db:migrate`, `db:rollback`) takes the database back. See
650
+ [below the catalog floor](../../docs/upgrading.md#below-the-catalog-floor).
651
+ - `bin/rails trellis:uninstall` removes everything Trellis has in the
652
+ database, targets included ([uninstalling](../../docs/operations.md#uninstalling)).
654
653
 
655
- Outside Rails, `require "trellis/release_check"` and call
656
- `Trellis::ReleaseCheck.call(root:, base:)`, which returns a result with
657
- `ok?` and `message`.
654
+ Each runs on the default instance and every one in `config.trellis.instances`.
658
655
 
659
656
  ## Testing
660
657
 
@@ -664,22 +661,22 @@ never changes, whether or not a worker runs. A target is an ordinary table a
664
661
  test fills itself.
665
662
 
666
663
  `config.trellis.off_in` (`%w[test]` unless you set it) names the environments
667
- Trellis is off in. It is read from every environment, so `db:prepare` or
668
- `db:test:prepare` run from development leaves Trellis out of the test database
669
- too. Where it is off:
670
-
671
- - Nothing connects at boot. `Trellis::Railtie.connect` and `trellis:migrate`
672
- warn and do nothing.
673
- - A schema load creates the targets as the plain tables `structure.sql`
674
- carries, with no capture triggers and nothing restored (the definitions
675
- stay unread in `trellis.restore_queue`). Rails' fixture foreign-key check
676
- passes, and the per-worker databases of `parallelize` load.
677
- - `define`, `apply` and `status` in a migration raise
678
- `ActiveRecord::MigrationError`: build the database by loading the schema.
679
- Migrating it from development (`db:prepare`) skips them, and the next
680
- `rails test` reloads it from the new dump.
681
- - `Trellis.enabled?` is false, for code that builds on Trellis (it is true
682
- without Rails). `Trellis.connect` itself is not gated.
664
+ Trellis's runtime is off in. Only the runtime is off there:
665
+
666
+ - Nothing connects at boot, and `Trellis::Railtie.connect` warns and does
667
+ nothing. `Trellis.enabled?` is false, for code that builds on Trellis (it
668
+ is true without Rails). `Trellis.connect` itself is not gated.
669
+ - The schema load (`maintain_test_schema!`, `db:test:prepare`), the
670
+ migration helpers and `trellis:migrate` run as they do where it's on, so
671
+ the test database has every target and definition, and a new define
672
+ reaches it the next time `rails test` reloads the schema. They connect to
673
+ the database Rails is loading or migrating (the per-worker databases of
674
+ `parallelize` included), and `trellis:migrate` to that environment's
675
+ `config.trellis.dump_database`, with `config.trellis.connect`'s other
676
+ options.
677
+ - With no worker, each definition stays `waiting_to_backfill` and sources
678
+ get no capture triggers, so test writes capture nothing and targets stay
679
+ empty until a test fills them.
683
680
 
684
681
  Stub a target's rows by hand, as the transform would write them; a model
685
682
  over the target ("Targets as models") writes here:
@@ -706,10 +703,10 @@ end
706
703
  ```
707
704
 
708
705
  It computes the target from its sources as they stand, as a fresh build
709
- would, with the `SELECT` the engine renders from the definition the schema
710
- load left in `trellis.restore_queue`. It doesn't exercise capture, the drain
711
- or any pause. A chained target refreshes its upstream first. A source the
712
- definition names without a schema resolves on the test's `search_path`. It
706
+ would, with the `SELECT` the engine renders from the recorded definition. It
707
+ doesn't exercise capture, the drain or any pause. A chained target refreshes
708
+ its upstream first. A source the definition names without a schema resolves
709
+ on the test's `search_path`. It
713
710
  raises `Trellis::ValidationError` where Trellis is on, since the engine
714
711
  maintains the target there (`trellis_on: true` writes anyway).
715
712
 
@@ -739,42 +736,39 @@ class EventCountTest < ActiveSupport::TestCase
739
736
  end
740
737
  ```
741
738
 
742
- Two more things need care with Trellis on in the test database:
739
+ A worker leaves capture triggers and built targets in the database it ran
740
+ on, so run these tests against a database of their own, or run `bin/rails
741
+ db:test:prepare` before the suite that has Trellis off.
743
742
 
744
- - **Rails 8.1's fixture foreign-key check** resolves every foreign key without
745
- Trellis's schema and fails with `PG::UndefinedTable`. Set
746
- `config.active_record.verify_foreign_keys_for_fixtures = false`, or
747
- `schema_search_path: "public,trellis"` on the test database. Rails 8.0
748
- doesn't need either.
749
- - **`parallelize(workers: n)`** loads the schema into one database per
750
- worker (`<name>_<i>` on Rails 8.1, `<name>-<i>` on 8.0), so each worker's
751
- `config.trellis.connect` has to name its own, and the handle does not
752
- survive the fork. Connect after the fork, not at boot
753
- (`config.trellis.connect_on_boot = false`), and register the hook before
754
- `require "rails/test_help"`, which is what runs the schema load:
743
+ With Trellis on in the test database, `parallelize(workers: n)` loads the
744
+ schema into one database per worker (`<name>_<i>` on Rails 8.1, `<name>-<i>`
745
+ on 8.0), so each worker's `config.trellis.connect` has to name its own, and
746
+ the handle does not survive the fork. Connect after the fork, not at boot
747
+ (`config.trellis.connect_on_boot = false`), and register the hook before
748
+ `require "rails/test_help"`, which is what runs the schema load:
755
749
 
756
- ```ruby
757
- # test/test_helper.rb
758
- require "active_support/testing/parallelization"
759
-
760
- ActiveSupport::Testing::Parallelization.after_fork_hook do |worker|
761
- trellis = Rails.application.config.trellis
762
- uri = URI.parse(trellis.connect.fetch(:url))
763
- suffix = ActiveRecord.version >= Gem::Version.new("8.1") ? "_" : "-"
764
- uri.path = "#{uri.path}#{suffix}#{worker}"
765
- trellis.connect = trellis.connect.merge(url: uri.to_s)
766
- end
750
+ ```ruby
751
+ # test/test_helper.rb
752
+ require "active_support/testing/parallelization"
753
+
754
+ ActiveSupport::Testing::Parallelization.after_fork_hook do |worker|
755
+ trellis = Rails.application.config.trellis
756
+ uri = URI.parse(trellis.connect.fetch(:url))
757
+ suffix = ActiveRecord.version >= Gem::Version.new("8.1") ? "_" : "-"
758
+ uri.path = "#{uri.path}#{suffix}#{worker}"
759
+ trellis.connect = trellis.connect.merge(url: uri.to_s)
760
+ end
767
761
 
768
- require "rails/test_help"
762
+ require "rails/test_help"
769
763
 
770
- class ActiveSupport::TestCase
771
- parallelize(workers: 2)
772
- # In a worker, after the schema load; in the one process of a run below
773
- # Rails' parallelization threshold, the first test. Declare it before any
774
- # setup that needs the handle (`resume_capture_disruptions`).
775
- setup { Trellis::Railtie.connect if Trellis::Instance.connected.empty? }
776
- end
777
- ```
764
+ class ActiveSupport::TestCase
765
+ parallelize(workers: 2)
766
+ # In a worker, after the schema load; in the one process of a run below
767
+ # Rails' parallelization threshold, the first test. Declare it before any
768
+ # setup that needs the handle (`resume_capture_disruptions`).
769
+ setup { Trellis::Railtie.connect if Trellis::Instance.connected.empty? }
770
+ end
771
+ ```
778
772
 
779
773
  ### Fixtures and bulk loads
780
774
 
@@ -824,7 +818,7 @@ them, so with `schema_format = :ruby` the dump (`db:migrate`'s and
824
818
  ```ruby
825
819
  # config/application.rb
826
820
  config.active_record.schema_format = :sql
827
- config.trellis.connect = { url: ENV.fetch("DATABASE_URL") }
821
+ config.trellis.connect = { url: ENV.fetch("TRELLIS_DATABASE_URL") }
828
822
  ```
829
823
 
830
824
  Nothing else is set up. The file has the application's tables, the target
@@ -861,11 +855,10 @@ How the restore works, and what it refuses, is in
861
855
  the test config's database, and its host, port, user, password and other
862
856
  libpq keywords (`sslmode`, `sslrootcert`, ...) where it names a non-blank
863
857
  value (its `url` when it has one).
864
- - A database of an environment named in `config.trellis.off_in` loads as
865
- plain tables and is dumped as Rails does. `db:prepare` in development
866
- skips the dump of such a test database, which would overwrite
867
- development's `structure.sql` with one that has no definitions
868
- ([Testing](#testing)).
858
+ - A database of an environment named in `config.trellis.off_in` loads and
859
+ dumps the same way, connecting to that database itself
860
+ ([Testing](#testing)). `db:prepare` in development skips the dump of such
861
+ a test database: the file is development's.
869
862
  - The hook adds each instance's exclusions (its Trellis schema, its ledgers)
870
863
  to the flags Rails passes `pg_dump`, and its `target_schema` to the
871
864
  `--schema` flags when Rails passes any. `pg_dump` can't leave out one
@@ -899,8 +892,7 @@ How the restore works, and what it refuses, is in
899
892
  the Rails integration (`trellis/railtie.rb`, `trellis/migration.rb`,
900
893
  `trellis/target.rb`),
901
894
  loaded only in an app that has Rails, and the test helpers
902
- (`trellis/test_support.rb`) and the release check
903
- (`trellis/release_check.rb`), each loaded only when required.
895
+ (`trellis/test_support.rb`), loaded only when required.
904
896
  - `ext/trellis_ruby/`: the extension crate, a member of the repository's
905
897
  Cargo workspace, and the `extconf.rb` that builds it with rb-sys.
906
898
  Plain-data conversion and error codes come from `clients/embed`
@@ -1729,11 +1729,12 @@ dependencies = [
1729
1729
 
1730
1730
  [[package]]
1731
1731
  name = "trellis"
1732
- version = "0.3.1"
1733
- source = "git+https://github.com/salesforce-misc/trellis?rev=dedfe5e5a25dc1ec39f9548382de7920c8e7526c#dedfe5e5a25dc1ec39f9548382de7920c8e7526c"
1732
+ version = "0.4.0"
1733
+ source = "git+https://github.com/salesforce-misc/trellis?rev=f1c4f2e3a5468e1c33c8dacf0475ba3de016702c#f1c4f2e3a5468e1c33c8dacf0475ba3de016702c"
1734
1734
  dependencies = [
1735
1735
  "deadpool",
1736
1736
  "deadpool-postgres",
1737
+ "futures-core",
1737
1738
  "getrandom 0.4.3",
1738
1739
  "metrics",
1739
1740
  "metrics-exporter-prometheus",
@@ -1751,8 +1752,8 @@ dependencies = [
1751
1752
 
1752
1753
  [[package]]
1753
1754
  name = "trellis-embed"
1754
- version = "0.3.1"
1755
- source = "git+https://github.com/salesforce-misc/trellis?rev=dedfe5e5a25dc1ec39f9548382de7920c8e7526c#dedfe5e5a25dc1ec39f9548382de7920c8e7526c"
1755
+ version = "0.4.0"
1756
+ source = "git+https://github.com/salesforce-misc/trellis?rev=f1c4f2e3a5468e1c33c8dacf0475ba3de016702c#f1c4f2e3a5468e1c33c8dacf0475ba3de016702c"
1756
1757
  dependencies = [
1757
1758
  "tracing",
1758
1759
  "trellis",
@@ -1760,7 +1761,7 @@ dependencies = [
1760
1761
 
1761
1762
  [[package]]
1762
1763
  name = "trellis_ruby"
1763
- version = "0.3.1"
1764
+ version = "0.4.0"
1764
1765
  dependencies = [
1765
1766
  "magnus",
1766
1767
  "rb-sys",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "trellis_ruby"
3
- version = "0.3.1"
3
+ version = "0.4.0"
4
4
  edition = "2024"
5
5
  publish = false
6
6
 
@@ -28,8 +28,8 @@ doctest = false
28
28
  ruby = ["dep:magnus", "dep:rb-sys"]
29
29
 
30
30
  [dependencies]
31
- trellis = { git = "https://github.com/salesforce-misc/trellis", rev = "dedfe5e5a25dc1ec39f9548382de7920c8e7526c" }
32
- trellis-embed = { git = "https://github.com/salesforce-misc/trellis", rev = "dedfe5e5a25dc1ec39f9548382de7920c8e7526c" }
31
+ trellis = { git = "https://github.com/salesforce-misc/trellis", rev = "f1c4f2e3a5468e1c33c8dacf0475ba3de016702c" }
32
+ trellis-embed = { git = "https://github.com/salesforce-misc/trellis", rev = "f1c4f2e3a5468e1c33c8dacf0475ba3de016702c" }
33
33
  magnus = { version = "0.9", optional = true, default-features = false, features = ["rb-sys"] }
34
34
  rb-sys = { version = "0.9", optional = true }
35
35