Skip to main content

Project Structure

User Project Structure

my-project/
├── db/ # User's database code (git tracked)
│ └── schema/ # Schema definitions
│ ├── infra/ # Roles, schemas, extensions
│ ├── extensions/
│ ├── types/
│ ├── enums/
│ ├── tables/
│ ├── views/
│ ├── functions/
│ ├── triggers/
│ ├── indexes/
│ ├── grants/ # Grant statements
│ └── seeds/ # Seed data
├── .postkit/ # PostKit runtime (gitignored)
│ └── db/ # All DB runtime files
│ ├── session.json # Session state
│ ├── committed.json # Committed migrations tracking
│ ├── plan.sql # Generated plan
│ ├── schema.sql # Generated schema
│ ├── session/ # Session migrations (temporary)
│ └── migrations/ # Committed migrations (for deploy)
├── postkit.config.json # Project configuration
├── .env # Environment variables (gitignored)
└── package.json

Schema Directory

The db/schema/ directory is organized into three categories:

Infrastructure (Handled Separately)

DirectoryDescriptionProcessed By
infra/Pre-migration: roles, schemas, extensionsApplied separately (excluded from pgschema)

Schema Objects (Processed by postkit db plan)

DirectoryDescriptionSupported by pgschema
types/Custom types✅ Yes
enums/ENUM types✅ Yes
tables/Table definitions✅ Yes
views/View definitions✅ Yes
functions/Function definitions✅ Yes
triggers/Trigger definitions✅ Yes
indexes/Index definitions✅ Yes

Post-Migration (Handled Separately)

DirectoryDescriptionProcessed By
grants/Grant statementsApplied separately
seeds/Seed dataApplied separately

Note: Cluster and database level commands (CREATE DATABASE, CREATE ROLE, CREATE EXTENSION, etc.) are not supported by pgschema. Use db/schema/infra/ or manual migrations instead.

PostKit Runtime Directory

The .postkit/ directory contains runtime files that are not tracked by git:

File/DirectoryDescription
session.jsonCurrent session state
committed.jsonCommitted migrations tracking
plan.sqlGenerated migration plan
schema.sqlGenerated schema from files
session/Session migrations (temporary, cleared on commit)
migrations/Committed migrations (for deployment)

Config File

postkit.config.json in your project root:

{
"db": {
"localDbUrl": "postgres://user:pass@localhost:5432/myapp_local",
"schemaPath": "db/schema",
"schema": "public",
"remotes": {
"dev": {
"url": "postgres://user:pass@host:5432/myapp",
"default": true
}
}
}
}