Skip to main content

Session State

The database module uses a session-based workflow. Session state is tracked in .postkit/db/session.json.

Session State Structure

{
"active": true,
"startedAt": "2026-02-11T12:00:00Z",
"clonedAt": "20260211120000",
"remoteName": "staging",
"localDbUrl": "postgres://user:pass@localhost:5432/myapp_local",
"remoteDbUrl": "postgres://user:pass@staging-host:5432/myapp",
"pendingChanges": {
"planned": false,
"applied": false,
"planFile": null,
"migrationFiles": [],
"description": null,
"schemaFingerprint": null,
"migrationApplied": false,
"grantsApplied": false,
"seedsApplied": false
}
}

Fields

FieldDescription
activeWhether a session is currently active
startedAtISO timestamp when session was started
clonedAtTimestamp when remote DB was cloned
remoteNameName of the remote that was cloned
localDbUrlLocal database connection URL
remoteDbUrlRemote database connection URL
pendingChangesObject tracking changes in the session

pendingChanges

FieldDescription
plannedWhether a plan has been generated
appliedWhether changes have been applied
planFilePath to the plan file
migrationFilesArray of migration file paths
descriptionMigration description
schemaFingerprintSHA-256 hash of schema files
migrationAppliedWhether dbmate migration was applied
grantsAppliedWhether grants were applied
seedsAppliedWhether seeds were applied

Session Lifecycle

  1. Start: postkit db start creates a new session
  2. Plan: postkit db plan generates a plan and updates state
  3. Apply: postkit db apply applies changes and updates state
  4. Commit: postkit db commit finalizes the session and clears it
  5. Abort: postkit db abort cancels the session and cleans up
FileDescription
.postkit/db/session.jsonCurrent session state
.postkit/db/committed.jsonCommitted migrations tracking
.postkit/db/plan.sqlGenerated migration plan
.postkit/db/schema.sqlGenerated schema from files
.postkit/db/session/Session migrations (temporary)
.postkit/db/migrations/Committed migrations (for deploy)