db/status.ts

Database status utility for CLI and dev workflows.

Queries migration state and table info without a running server. Returns structured data that consumer scripts can print however they like.

Declarations
#

5 declarations

view source

DbStatus
#

db/status.ts view source

DbStatus

Full database status snapshot.

connected

Whether the database is reachable.

type boolean

error

Error message if connection failed.

type string

table_count

Number of public tables.

type number

tables

Per-table row counts.

type Array<TableStatus>

migrations

Per-namespace migration status.

type Array<MigrationStatus>

format_db_status
#

db/status.ts view source

(status: DbStatus): string

Format a DbStatus as a human-readable string for CLI output.

status

the status to format

returns

string

multi-line string suitable for console output

MigrationStatus
#

db/status.ts view source

MigrationStatus

Migration status for a single namespace.

namespace

type string

current_version

Current applied version (0 if never migrated).

type number

available_version

Total available migrations in the namespace.

type number

up_to_date

Whether the schema is up to date.

type boolean

query_db_status
#

db/status.ts view source

(db: Db, namespaces?: MigrationNamespace[] | undefined): Promise<DbStatus>

Query database status including connectivity, tables, and migration versions.

Designed for CLI db:status commands. Does not modify the database.

db

the database instance

type Db

namespaces?

migration namespaces to check versions for

type MigrationNamespace[] | undefined
optional

returns

Promise<DbStatus>

a snapshot of database status

TableStatus
#