# Give every app its own database

What's new in Tray Helix · 4 November 2026 · https://helix.tray.ai/whats-new/managed-database/

Tray Helix now gives a project its own managed Postgres database. A team describes its tables in db/schema.ts with Drizzle ORM, and the first deploy creates the database while every later deploy applies schema changes before the new code goes live. Functions query it through ctx.db(), a typed query builder, and helix dev runs a local in-memory copy that never touches deployed data.

**Available in:** Every Helix edition, with Helix CLI and SDK 1.20.0 or later. Database use is billed as active time, which stops when the database is idle.

Most internal apps outgrow a spreadsheet the week they ship. They need records that relate to each other: requests and the people who approve them, accounts and their contracts, tickets and their history. Until now that meant asking for a database, waiting for someone to set it up, and keeping its schema in step with the code by hand.

Now in Helix, the database comes with the app. You describe the tables in one file, and the deploy does the rest: it creates the database the first time, and on every deploy after that it changes the schema to match your file before the new code goes live.

**What that gives the team building it:**

- **No database to request or run.** A project that has a `db/schema.ts` gets its own Postgres database, with pgvector included. A project without one has no database.
- **No migrations to write.** You edit the schema and deploy. Helix works out what changed and applies it.
- **Typed queries.** Functions get a Drizzle query builder typed from the schema, so a wrong column name fails in the editor, not in production. The AI assistant writes it the way it writes any Drizzle code.
- **A safe local copy.** `helix dev` runs an in-memory Postgres built from the same schema. It starts fresh on every save and can't reach deployed data.

**What it gives IT:**

- **One database per app, and only that app can read it.** No shared database for every team's experiments.
- **Schema changes only through a deploy.** The app's functions can read and write data but can't create, change or drop a table. The only way a table changes is a deploy, which is reviewed and recorded like any other.
- **Destructive changes stopped at the door.** A deploy that would drop a table or column is refused before it runs.

## An example

A sales team runs a deal desk app on Helix for discount approvals. Requests come in through a form, and a manager approves or declines them. Here's the app getting its database.

### 1. The team describes the data

They ask the AI assistant for two tables, discount requests and approvals, and it writes them into `db/schema.ts`: the account, the discount asked for, who asked, and each approval with the approver and a timestamp.

### 2. The first deploy creates the database

The team runs `helix deploy`. Helix sees the schema, creates the project's Postgres database, applies the schema and only then puts the new code live. The form's function writes each request with one call, and the manager's view reads the open ones.

### 3. They add a field the next week

Finance wants a reason code on every request. The assistant adds a column with a default to the schema, and the next deploy adds it to the live table before the code that uses it ships. Nobody writes a migration.

### 4. A risky change gets stopped

Later someone renames the discount column in the same change that drops the old one. Helix reads that as data that would disappear, and the deploy is refused with a message saying to make the change in steps. The live app keeps running untouched.

## What else you could build

- **An asset tracker** that records laptops, who has them and when they're due back.
- **A vendor onboarding app** that keeps each vendor, its documents and its approval history together.
- **A support triage tool** that stores tickets with embeddings in a vector column, so similar cases can be found.
- **A field service log** that relates sites, visits and parts used.

## Before you build one

**Rename and remove in steps.** Add the new column, copy the data across with a one-off function, and remove the old column in a later deploy. A deploy never carries data, only schema.

**The first call after a quiet spell is slower.** An idle database wakes when it's next used. Helix retries a call that arrives while it wakes, for up to about 30 seconds. A statement that fails for any other reason isn't retried, so a write never runs twice.

**Some column types need a cast.** Enum, numeric, array and vector values fail without one. Since Helix 1.28.0 the SDK has column types that cast for you, and `helix dev` fails the same way the deployed database does, so you catch it locally.

**Big results are refused.** A single result over about 1 MiB is rejected, so page large reads.

**It's for data that outlives a request.** For a simple value or a flag, the project's key-value store is lighter.

How to set it up, change the schema and query it is in the docs linked above.

## Links

- Release note: [Helix 1.20.0](https://helix.tray.ai/documentation/releases/1200/)
- Docs: [Database guide](https://helix.tray.ai/documentation/guides/database/)
- Docs: [ctx.db() reference](https://helix.tray.ai/documentation/reference/context/db/)
- Docs: [Columns that need a cast](https://helix.tray.ai/documentation/guides/database/#columns-that-need-a-cast)
- Docs: [Remove or rename in steps](https://helix.tray.ai/documentation/guides/database/#remove-or-rename-in-steps)

## Questions

### Do I write migration files?

No. The project holds only db/schema.ts. On each deploy, Helix compares it with the schema the database already has, generates the migration and applies it before the new code goes live. helix db migrations lists what has been applied.

### What happens to a change that would delete data?

The deploy is refused. Dropping a table or column, or narrowing a type, is destructive, so you make it in steps across separate deploys: add the new shape, copy the data across, then remove the old one.

### Can another app read this database?

No. The database belongs to one project, and no other project can read it. Every function in that project reads and writes the same database.

### Can I use it while developing locally?

Yes. helix dev runs an in-memory Postgres built from your schema. It starts empty on every save and restart, and it never touches a deployed database.

