zio.blocks.data.migration

Members list

Type members

Classlikes

case object BuildInfo

This object was generated by sbt-buildinfo.

This object was generated by sbt-buildinfo.

Attributes

Source
BuildInfo.scala
Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
BuildInfo.type
final case class DataVersion(epoch: Int, major: Int, minor: Int, timestampMillis: Option[Long] = ...)

Semantic version for data schemas.

Semantic version for data schemas.

Value parameters

epoch

Major breaking epoch (incompatible with prior epochs)

major

Major version within epoch

minor

Minor/patch version

timestampMillis

Optional creation timestamp (epoch millis)

Attributes

Source
core.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
sealed trait ExecutionModel

Execution model for migration strategies.

Execution model for migration strategies.

  • Tiny: in-memory, single-transaction, minimal overhead
  • Small: batch-oriented, moderate resource use
  • Large: streaming/out-of-core, resumable, high resource tolerance

Attributes

Companion
object
Source
core.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Large
object Small
object Tiny

Attributes

Companion
trait
Source
core.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
final class LargeMigrator[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)

B-Large: incremental worker that processes migration queue until empty. Supports pause/resume and progress reporting.

B-Large: incremental worker that processes migration queue until empty. Supports pause/resume and progress reporting.

The lifecycle methods (init, fence, drain, complete) are internally consistent but are expected to be driven from a single thread; pause and resume are safe to call from other threads while run() or drain() is in flight.

Attributes

Source
LargeMigrator.scala
Supertypes
class Object
trait Matchable
class Any

Helpers for the optional data_migrations metadata table.

Helpers for the optional data_migrations metadata table.

Stores provenance for migrated aggregates when resume/re-processing or audit trails are required. Not required for simple in-place migrations.

Attributes

Source
MigrationMetadata.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object QueueTable

Helpers for migration queue tables used by migration workers, dialect-driven to support both PostgreSQL and SQLite.

Helpers for migration queue tables used by migration workers, dialect-driven to support both PostgreSQL and SQLite.

Queue tables store IDs of aggregates pending migration. Workers dequeue batches via SELECT ... FOR UPDATE SKIP LOCKED on PostgreSQL; SQLite uses a plain LIMIT with the write lock held via IMMEDIATE (SQLite connections via JdbcTransactor.fromUrl/sqlite or any pooled/wrapped DataSource are configured per-transaction with busy_timeout=5000 and IMMEDIATE via isWrapperFor/unwrap, so transact reserves the write lock and waits on contention; connect is configured similarly but does not begin a transaction or reserve the lock — only transact issues BEGIN IMMEDIATE; see PR #1534 discussion_r3863454094).

Attributes

Source
QueueTable.scala
Supertypes
class Object
trait Matchable
class Any
Self type
QueueTable.type
object ShadowTable

Helpers for creating and swapping shadow tables during large migrations.

Helpers for creating and swapping shadow tables during large migrations.

Pattern: CREATE TABLE users_v2 LIKE users; migrate into v2; swap atomically.

Attributes

Source
ShadowTable.scala
Supertypes
class Object
trait Matchable
class Any
Self type
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.

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
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Source
core.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait TargetStrategy

Target write strategy (orthogonal to ExecutionModel).

Target write strategy (orthogonal to ExecutionModel).

  • InPlace: mutate existing table/storage
  • ShadowTable: suffix appended to the base table name, then swap/rename

Attributes

Companion
object
Source
core.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object InPlace
class ShadowTable

Applies a TargetStrategy, providing the actual table name to write to and handling shadow table lifecycle (create, write, swap).

Applies a TargetStrategy, providing the actual table name to write to and handling shadow table lifecycle (create, write, swap).

Attributes

Source
TargetStrategyApplier.scala
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class TinyMigrator(transactor: Transactor)

A-Tiny: startup migration that runs schema DDL within a single transaction.

A-Tiny: startup migration that runs schema DDL within a single transaction.

Usage:

class MyStartupMigrations(transactor: Transactor) extends TinyMigrator(transactor) {
 def run()(using tx: DbTx): Unit = {
   Ddl.createTable("users", IndexedSeq(
     ColumnDef("id", "BIGSERIAL", nullable = false),
     ColumnDef("email", "TEXT", nullable = false)
   )).update
 }
}

Attributes

Source
TinyMigrator.scala
Supertypes
class Object
trait Matchable
class Any