SmallMigrator

zio.blocks.data.migration.SmallMigrator
final class SmallMigrator[A, B, ID1, ID2](repoV1: Repo[A, ID1], repoV2: Repo[B, ID2], migration: Migration[A, B], queueTable: String, batchSize: Int, target: TargetStrategy, captureTriggers: Boolean = ...)(using transactor: Transactor, codecId: DbCodec[ID1], dialect: Dialect, ev: ID1 =:= ID2)

A-Small: queue-based batch migration worker.

Dequeues IDs from a queue table, reads entities via Repo.findAll, applies Migration[A,B], and writes to the target repo. Rows whose source entity no longer exists are deleted from the target (ADR Decision 3). One transaction per batch. Supports both in-place and shadow targets.

Attributes

Source
SmallMigrator.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def complete(): Unit

Finalize the migration. For ShadowTable strategy, performs the atomic swap (shadow table replaces the live table). Requires init() first and refuses to run while the queue still has pending items — draining is the caller's responsibility.

Finalize the migration. For ShadowTable strategy, performs the atomic swap (shadow table replaces the live table). Requires init() first and refuses to run while the queue still has pending items — draining is the caller's responsibility.

Attributes

Source
SmallMigrator.scala
def init(): Unit

Prepare the target table. For ShadowTable strategy, creates the shadow table via TargetStrategyApplier.prepare. When captureTriggers is enabled, installs capture triggers on the source table. Safe to call multiple times (idempotent after first success).

Prepare the target table. For ShadowTable strategy, creates the shadow table via TargetStrategyApplier.prepare. When captureTriggers is enabled, installs capture triggers on the source table. Safe to call multiple times (idempotent after first success).

Attributes

Source
SmallMigrator.scala
def previewSql(): Vector[String]

Pure preview of init/run SQL without opening any connection.

Pure preview of init/run SQL without opening any connection.

Returns init/run statement texts (queue DDL, shadow create/rename, triggers, dequeue template) rendered against the ambient dialect. Does NOT call Transactor.

Attributes

Source
SmallMigrator.scala
def processBatch(): Int

Processes one batch. Returns count of migrated rows.

Processes one batch. Returns count of migrated rows.

Attributes

Source
SmallMigrator.scala