playerthree/postgres
playerthree/postgres — durable storage for PlayerThree on PostgreSQL (e.g. Railway's DATABASE_URL): commander
rosters, OAuth connections, the published-policy pool and the session history, all game-scoped. Opening applies the
pending migrations — PlayerThree's own (./migrations, scope playerthree), then the game's — each in its own
transaction, under a session advisory lock so concurrent instances never migrate twice.
Each store runs its operations one at a time in issue order (the connection pool could otherwise reorder them), and
close() drains every store before it ends the pool. The connection string is never logged.
Interfaces
PostgresStorage
Defined in: packages/playerthree/src/postgres/index.ts:37
Opened PostgreSQL storage: game-scoped stores to pass to the host, the MCP endpoint and the series runner.
Methods
close()
close(): Promise<void>;Defined in: packages/playerthree/src/postgres/index.ts:47
Waits for every store's queued operations, then ends the pool. Idempotent.
Returns
Promise<void>
commanderLog()
commanderLog(game): CommanderLogStore;Defined in: packages/playerthree/src/postgres/index.ts:42
Parameters
| Parameter | Type |
|---|---|
game | string |
Returns
commanders()
commanders(game): CommanderStore;Defined in: packages/playerthree/src/postgres/index.ts:38
Parameters
| Parameter | Type |
|---|---|
game | string |
Returns
connections()
connections(game): ConnectionStore;Defined in: packages/playerthree/src/postgres/index.ts:39
Parameters
| Parameter | Type |
|---|---|
game | string |
Returns
history()
history(game): HistoryStore;Defined in: packages/playerthree/src/postgres/index.ts:41
Parameters
| Parameter | Type |
|---|---|
game | string |
Returns
pool()
pool(game): PoolStore;Defined in: packages/playerthree/src/postgres/index.ts:40
Parameters
| Parameter | Type |
|---|---|
game | string |
Returns
query()
query<R>(text, params?): Promise<R[]>;Defined in: packages/playerthree/src/postgres/index.ts:45
Parameterized query for the game's own tables (rows).
Type Parameters
Parameters
| Parameter | Type |
|---|---|
text | string |
params? | unknown[] |
Returns
Promise<R[]>
series()
series(game): SeriesStore;Defined in: packages/playerthree/src/postgres/index.ts:43
Parameters
| Parameter | Type |
|---|---|
game | string |
Returns
PostgresStorageOptions
Defined in: packages/playerthree/src/postgres/index.ts:27
Options of openPostgresStorage.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
max? | number | Pool size (default 10). | packages/playerthree/src/postgres/index.ts:31 |
migrations? | object | The game's own migrations: a directory of NNN_name.sql files applied in name order after PlayerThree's, tracked under scope. | packages/playerthree/src/postgres/index.ts:33 |
migrations.dir | string | - | packages/playerthree/src/postgres/index.ts:33 |
migrations.scope | string | - | packages/playerthree/src/postgres/index.ts:33 |
url | string | postgres:// connection string (e.g. Railway's DATABASE_URL). | packages/playerthree/src/postgres/index.ts:29 |
Variables
PLAYERTHREE_SCOPE
const PLAYERTHREE_SCOPE: "playerthree" = 'playerthree';Defined in: packages/playerthree/src/postgres/ledger.ts:4
Migration scope of PlayerThree's own schema; its tables are named playerthree_*.
Functions
openPostgresStorage()
function openPostgresStorage(opts): Promise<PostgresStorage>;Defined in: packages/playerthree/src/postgres/index.ts:119
Connects, applies pending migrations (one transaction each, under a pg advisory lock), returns the storage.
Parameters
| Parameter | Type |
|---|---|
opts | PostgresStorageOptions |
Returns
Promise<PostgresStorage>
