> ## Documentation Index
> Fetch the complete documentation index at: https://docs.insforge.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Database

> Every InsForge project ships a full Postgres database with typed REST and SDK endpoints, row-level security, pgvector, and realtime change feeds built in.

Every InsForge project comes with a full [Postgres](https://www.postgresql.org/) database. Every table is automatically a typed REST and SDK endpoint. Auth tokens scope every read and write through row-level security. The same Postgres handles relational queries, semantic search via pgvector, and realtime change feeds.

![InsForge dashboard table editor showing a messages table with typed columns](https://mintcdn.com/insforge-468ccf39/BaXMFYmXPQFuLF7H/images/database-table-editor.png?fit=max\&auto=format\&n=BaXMFYmXPQFuLF7H\&q=85\&s=10bf2755b0be3e8a27e975e22a3e3790)

The table editor: typed columns, inline editing, CSV import, and a SQL studio.

> [!NOTE]
>
> **Looking for file storage?** Use [Storage](https://docs.insforge.dev/core-concepts/storage/overview.md) for images, PDFs, and other binary content. The database stores rows; storage stores objects.

```mermaid theme={null}
graph TB
    Client[Client Application] --> SDK[InsForge SDK]
    SDK --> API[InsForge API]
    API --> PostgREST[PostgREST v12.2]
    PostgREST --> PG[(PostgreSQL 15)]
    API --> PG

    PG --> RLS[Row Level Security]
    PG --> Triggers[Database Triggers]
    PG --> Functions[Stored Functions]
    PG --> Schemas[Multiple Schemas]

    style Client fill:#1e293b,stroke:#475569,color:#e2e8f0
    style SDK fill:#1e40af,stroke:#3b82f6,color:#dbeafe
    style API fill:#166534,stroke:#22c55e,color:#dcfce7
    style PostgREST fill:#c2410c,stroke:#fb923c,color:#fed7aa
    style PG fill:#0e7490,stroke:#06b6d4,color:#cffafe
    style RLS fill:#4c1d95,stroke:#8b5cf6,color:#ede9fe
    style Triggers fill:#4c1d95,stroke:#8b5cf6,color:#ede9fe
    style Functions fill:#4c1d95,stroke:#8b5cf6,color:#ede9fe
    style Schemas fill:#4c1d95,stroke:#8b5cf6,color:#ede9fe
```

## Features

### Tables as APIs

Define a table and you immediately get REST endpoints plus a typed SDK client for it. No code generation step. The auth JWT scopes every query through RLS.

### Migrations

Track and apply SQL changes in order. [Migrations](https://docs.insforge.dev/core-concepts/database/migrations.md) ship as plain `.sql` files in your repo, applied with `npx @insforge/cli db migrations up --all` or via the MCP tool.

### Branching

Spin up an isolated database branch to test risky schema changes against a copy of production data. See [Branching](https://docs.insforge.dev/agent-native/branching.md).

### pgvector

Native vector search for embeddings, with HNSW and IVFFlat indexes. See [pgvector](https://docs.insforge.dev/core-concepts/database/pgvector.md).

### Row-level security

Postgres RLS policies enforce access at the row level. Policies read the auth JWT, so the same rule applies to REST queries, SDK calls, realtime subscriptions, and storage requests.

## Concepts

> [card] [Migrations](https://docs.insforge.dev/core-concepts/database/migrations.md)
>
> Apply SQL changes in order, safely.

> [card] [Branching](https://docs.insforge.dev/agent-native/branching.md)
>
> Isolated databases for preview and risky changes.

> [card] [pgvector](https://docs.insforge.dev/core-concepts/database/pgvector.md)
>
> Vector search for embeddings.

## Build with it

> [card] [TypeScript SDK](https://docs.insforge.dev/sdks/typescript/database.md)
>
> Typed queries, inserts, and updates from Node, browser, and edge.

> [card] [Swift SDK](https://docs.insforge.dev/sdks/swift/database.md)
>
> Native Swift database client for iOS and macOS.

> [card] [Kotlin SDK](https://docs.insforge.dev/sdks/kotlin/database.md)
>
> Coroutines-first database client for Android and JVM.

> [card] [REST API](https://docs.insforge.dev/sdks/rest/database.md)
>
> Plain HTTP database endpoints, callable from any language.

## Next steps

* Set up the [CLI](https://docs.insforge.dev/quickstart.md) to link your project (the recommended path).
* Browse the [TypeScript SDK reference](https://docs.insforge.dev/sdks/typescript/database.md) for typed queries.
