Custom tables
Use custom tables for records your organisation maintains, such as orders or inventory. Processes can write to these tables, and Lists can present the records in the Dashboard. Custom tables live in the same database as Process Focus system tables.
Define a table
Section titled “Define a table”In a project created with pfcli init, Drizzle Kit reads the exported table
definitions in src/schema/schema.ts. Add Drizzle ORM as a project dependency
if it isn’t already installed:
bun add drizzle-orm@1.0.0-rc.6Add this table to src/schema/schema.ts:
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"
export const webOrders = sqliteTable("web_orders", { id: text().primaryKey(), sku: text().notNull(), quantity: integer().notNull(),})Use sqliteTable for the default local and cloud setup. If you’re defining
the table for PostgreSQL, use pgTable instead:
import { integer, pgTable, text } from "drizzle-orm/pg-core"
export const webOrders = pgTable("web_orders", { id: text().primaryKey(), sku: text().notNull(), quantity: integer().notNull(),})Generate a migration
Section titled “Generate a migration”After adding or changing a table, generate a migration from the organisation directory. For the default SQLite configuration, run:
SQLITE_DATABASE_PATH=./db/pf.db bunx drizzle-kit generateReview the generated SQL and commit the files in drizzle/ with the schema
change. In the default SQLite setup, local pfcli import and Process Focus
cloud deployments apply pending migrations automatically.
PostgreSQL
Section titled “PostgreSQL”For the pgTable example, generate PostgreSQL migrations in a separate
directory so Drizzle Kit does not reuse SQLite migration history:
bunx drizzle-kit generate --dialect=postgresql --schema=./src/schema/schema.ts --out=./drizzle-postgresGeneration does not need a database connection. Review and commit the files
in drizzle-postgres/ with the schema change, then apply them through your
PostgreSQL migration workflow.