SqlMigration

zio.blocks.sql.SqlMigration
trait SqlMigration

SQL generation for the data-migration queue machinery.

All identifier parameters (table, col, shadowName, sourceTable, sourceIdColumn, queueKeyColumn) must be bare, pre-validated SQL identifiers — never user input, never schema-qualified, never quoted. Valid identifiers match [A-Za-z_][A-Za-z0-9_]*. Each method enforces this whitelist up front via SqlIdentifier.validate (same package, no new API) so the documented contract holds mechanically rather than by convention. Implementations interpolate the validated identifiers into DDL/DML as-is.

Attributes

Source
Dialect.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Dialect
object Postgres
object SQLite

Members list

Value members

Abstract methods

def createQueueTableDDL(table: String, col: String): String

Idempotent CREATE TABLE IF NOT EXISTS DDL for the dirty-key queue table.

Idempotent CREATE TABLE IF NOT EXISTS DDL for the dirty-key queue table.

Attributes

Source
Dialect.scala
def createShadowTableDDL(shadowName: String, sourceTable: String): String

Idempotent shadow-table DDL copying sourceTable structure; unsupported on SQLite (raises UnsupportedOperationException).

Idempotent shadow-table DDL copying sourceTable structure; unsupported on SQLite (raises UnsupportedOperationException).

Attributes

Source
Dialect.scala
def createTriggerDDL(queueTable: String, sourceTable: String, sourceIdColumn: String, queueKeyColumn: String): List[String]

Statements installing capture triggers that upsert source-row keys into the queue table. Must be idempotent (safe to re-run on restart).

Statements installing capture triggers that upsert source-row keys into the queue table. Must be idempotent (safe to re-run on restart).

Attributes

Source
Dialect.scala
def dequeueSQL(table: String, col: String, batchSize: Int): String

SELECT claiming up to batchSize queue keys, ordered by key; on PostgreSQL the claim locks rows with FOR UPDATE SKIP LOCKED.

SELECT claiming up to batchSize queue keys, ordered by key; on PostgreSQL the claim locks rows with FOR UPDATE SKIP LOCKED.

Attributes

Source
Dialect.scala

Abstract fields

val supportsSkipLocked: Boolean

Whether dequeueSQL uses FOR UPDATE SKIP LOCKED (PostgreSQL only).

Whether dequeueSQL uses FOR UPDATE SKIP LOCKED (PostgreSQL only).

Attributes

Source
Dialect.scala