Guides

Database

Declare a named Postgres database and tables in database.ts.

Every project has one database.ts. Default-export defineDatabase with a name and Drizzle pgTable definitions. robodev-lib re-exports the Drizzle helpers you need (pgTable, text, uuid, eq, and so on).

database.ts

import { defineDatabase, integer, pgTable, text, uuid } from "robodev-lib";
export const planets = pgTable("planets", {
id: uuid("id").primaryKey().defaultRandom(),
name: text("name").notNull(),
moons: integer("moons").default(0),
});
export default defineDatabase({
name: "space",
tables: { planets },
});

Database name

The name must be lowercase, start with a letter, and use only a-z, 0-9, and _. Starbase creates that tenant database on first deploy if it does not exist yet. Existing unused databases are left alone.

Schema sync

There are no migration files. Deploy compares database.ts to the live schema and applies the difference. Adding tables or columns is applied automatically. Dropping columns or tables is treated as destructive and requires confirmation or --force.

Import table objects from database.ts into your API files so handlers and schema stay in one place.