ShadowTable

zio.blocks.data.migration.ShadowTable
object ShadowTable

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

Members list

Value members

Concrete methods

def create[E](table: Table[E], suffix: String)(using con: DbCon, dialect: Dialect): String

Creates a shadow table by copying structure from the source table. Uses the given dialect to generate database-appropriate DDL — CREATE TABLE ... (LIKE ... INCLUDING ALL) on PostgreSQL, or raises an error on SQLite (which requires manual DDL).

Creates a shadow table by copying structure from the source table. Uses the given dialect to generate database-appropriate DDL — CREATE TABLE ... (LIKE ... INCLUDING ALL) on PostgreSQL, or raises an error on SQLite (which requires manual DDL).

Attributes

Source
ShadowTable.scala
def createPreview[E](table: Table[E], suffix: String)(using dialect: Dialect): String

Pure shadow-create DDL for the given dialect.

Pure shadow-create DDL for the given dialect.

Attributes

Source
ShadowTable.scala
def swap(tableName: String, suffix: String)(using con: DbCon): (String, String)

Atomically swaps the live table with the shadow table.

Atomically swaps the live table with the shadow table.

Postgres: renames live → live_old_suffix, shadow → live. Caller is responsible for dropping the old table after verification.

Attributes

Source
ShadowTable.scala
def swapPreview(tableName: String, suffix: String): List[String]

Pure swap (rename) statements.

Pure swap (rename) statements.

Attributes

Source
ShadowTable.scala