Skip to main content

SchemaVersionRegistry

@webda/sql


Class: SchemaVersionRegistry

Defined in: packages/sql/src/relational/versions.ts:132

The versions of a store in the Registry: reads the live ones, registers and heartbeats the running one, retires

Constructors​

Constructor​

new SchemaVersionRegistry(options): SchemaVersionRegistry

Defined in: packages/sql/src/relational/versions.ts:137

Create a new SchemaVersionRegistry instance

Parameters​

options​

SchemaVersionRegistryOptions

the store, the liveness window and the logger

Returns​

SchemaVersionRegistry

Properties​

options​

readonly options: SchemaVersionRegistryOptions

Defined in: packages/sql/src/relational/versions.ts:137

the store, the liveness window and the logger

Methods​

all()​

all(): Promise<SchemaVersion[]>

Defined in: packages/sql/src/relational/versions.ts:170

Every version of the store, live, expired or retired

Returns​

Promise<SchemaVersion[]>

the versions

Throws​

SchemaRegistryError when the registry cannot be read


check()​

check(plan, allowIncompatible?): Promise<{ changes: SchemaChange[]; live: SchemaVersion[]; }>

Defined in: packages/sql/src/relational/versions.ts:220

Check the plan against the live versions, logging every change

Parameters​

plan​

RelationalSchemaPlan

the plan of this version

allowIncompatible?​

string[]

the elements whose BLOCK changes are accepted

Returns​

Promise<{ changes: SchemaChange[]; live: SchemaVersion[]; }>

the live versions and the changes

Throws​

SchemaIncompatibleError when a change blocks

Throws​

SchemaRegistryError when the registry cannot be read


compare()​

compare(plan, live, allowIncompatible?): SchemaChange[]

Defined in: packages/sql/src/relational/versions.ts:204

Compare the plan with the live versions

Parameters​

plan​

RelationalSchemaPlan

the plan of this version

live​

SchemaVersion[]

the versions to compare with

allowIncompatible?​

string[]

the elements whose BLOCK changes are accepted

Returns​

SchemaChange[]

the changes, forced ones marked


find()​

find(version): Promise<SchemaVersion[]>

Defined in: packages/sql/src/relational/versions.ts:193

Find operation

Parameters​

version​

string

an identifier (<store>:<appVersion>:<planHash>), an application version or a plan hash

Returns​

Promise<SchemaVersion[]>

the matching versions


heartbeat()​

heartbeat(version, extra?): Promise<void>

Defined in: packages/sql/src/relational/versions.ts:283

Refresh the heartbeat of this instance with a partial write: other instances' entries are kept, the ones silent for longer than the liveness window are dropped

Parameters​

version​

SchemaVersion

the version

extra?​

Partial<Pick<SchemaVersion, "status" | "forced">> = {}

other attributes to patch

Returns​

Promise<void>


isInMemory()​

isInMemory(): boolean

Defined in: packages/sql/src/relational/versions.ts:152

Whether the Registry is in memory: versions of other processes are invisible

Returns​

boolean

true when the registry is a MemoryStore


live()​

live(now?): Promise<SchemaVersion[]>

Defined in: packages/sql/src/relational/versions.ts:184

The versions still running: LIVE with a heartbeat within the liveness window

Parameters​

now?​

Date = ...

the current time

Returns​

Promise<SchemaVersion[]>

the live versions


register()​

register(appVersion, plan, forced?): Promise<SchemaVersion>

Defined in: packages/sql/src/relational/versions.ts:246

Record this version as live: created on its first init(), heartbeated afterwards

Parameters​

appVersion​

string

the application version

plan​

RelationalSchemaPlan

the plan

forced?​

string[] = []

the allowIncompatible entries that downgraded a change

Returns​

Promise<SchemaVersion>

the version

Throws​

SchemaRegistryError when the registry cannot be written


repository()​

protected repository(): Repository<typeof SchemaVersion>

Defined in: packages/sql/src/relational/versions.ts:143

The repository of the versions: the Registry catch-all, through the class the application registered

Returns​

Repository<typeof SchemaVersion>

the repository


retire()​

retire(version): Promise<SchemaVersion[]>

Defined in: packages/sql/src/relational/versions.ts:303

Retire versions: they no longer count for the compatibility checks and the contract phase

Parameters​

version​

string

an identifier, an application version or a plan hash

Returns​

Promise<SchemaVersion[]>

the retired versions


appVersion()​

static appVersion(override?): string

Defined in: packages/sql/src/relational/versions.ts:161

The version of the application: the appVersion parameter of the store, else package.json

Parameters​

override?​

string

the parameter

Returns​

string

the version