PostgreSQL for startups on DASTER

A PostgreSQL database for your startup's app on DASTER: sizes, tables and SQL, row-level security, backups and how hosted apps connect.

Last updated

DASTER gives each project a PostgreSQL database as part of Backend Cloud. You create it in the Dashboard or with one API call, work with tables, SQL, migrations and row-level security policies, and get scheduled backups. Apps hosted on DASTER receive DATABASE_URL by themselves. Connections from outside DASTER are not open yet.

What do you get?

  • PostgreSQL in Mumbai (ap-south-1), in the project's Development environment.
  • Tables: list tables, see columns and the first 100 rows, insert, edit and delete rows, and change the structure (add a column, rename, change type, index, relationship).
  • SQL Editor: one statement at a time, within a time limit, with up to 200 rows returned. Migrations apply named SQL statements in one transaction.
  • Extensions: pgcrypto, uuid-ossp, citext and hstore.
  • Row-level security: tables you create on the Tables tab deny client access by default. Backend Cloud › Policies creates policies from four templates.
  • Backups: Back up now, scheduled backups every 6, 12 or 24 hours as your size allows, and Restore into a new generation. A restore never overwrites the live database.
  • Poolers: a transaction pooler and a session pooler, TLS only (sslmode=verify-full), SCRAM-SHA-256, and up to 20 allowed address ranges.
  • The rest of Backend Cloud in the same project: Authentication, Storage and Realtime.

Which sizes are there?

SizeStorageConnectionsAdded storageAvailable
Free512 MB10NoneYes
Nano512 MB10Up to 2 GBYes
Small2 GB30Up to 8 GBNot yet
Medium8 GB60Up to 24 GBNot yet

Each organization has one Free database: your first PostgreSQL database is Free, later ones start as Nano. Storage is added in 1 GB steps. These sizes and limits are not final.

What are the limits today?

  • Only apps hosted on DASTER can connect. psql, pg_dump and apps hosted elsewhere cannot connect yet; use the SQL Editor, the API or the data API instead.
  • Point-in-time restore is not available on the Mumbai database server yet. Scheduled backups and restoring a backup work.
  • When a database reaches its storage cap it becomes read-only: writes are refused with database_storage_full, while reads, deleting rows, TRUNCATE and DROP keep working.
  • Not available yet: the Functions, Triggers, Roles and Advisors tabs, Create index and slow query text.
  1. Create the database

    In your project, open Backend Cloud and choose Set up Backend Cloud. The summary shows the size you will get; confirm it. The setup page follows the database until it is ready.

    With the API:

    HTTP
    POST /v1/projects/{projectId}/backend?organizationId={organizationId}
    Content-Type: application/json
    Idempotency-Key: backend-acme-1
    
    { "size": "nano" }

    Without a body, DASTER chooses the size for you: Free first, then Nano.

  2. Create your tables

    Create tables on the Tables tab, or write them as a migration on Migrations:

    SQL
    create table public.todos (
      id bigint generated always as identity primary key,
      title text not null,
      done boolean not null default false,
      created_at timestamptz not null default now()
    );

    When browser code should read a table, add a policy under Backend Cloud › Policies.

  3. Connect a hosted app

    Deploy your app on Hosting. At every deployment, once Backend Cloud is ready, the app receives DATABASE_URL (the session pooler, with sslmode=verify-full), DASTER_URL and DASTER_SERVER_KEY. Use DATABASE_URL with your PostgreSQL driver, or the SDK on your server:

    TypeScript
    import { createServiceClient } from '@dasterhq/daster';
    
    const db = createServiceClient({
      projectId: process.env.DASTER_PROJECT_ID!,
      serverKey: process.env.DASTER_SERVER_KEY!,
    });
    
    const { rows } = await db.database.select('todos', { eq: { done: false }, limit: 20 });

    The server key bypasses row-level security, so filter every query yourself. Set DASTER_PROJECT_ID yourself.

  4. Check your backups

    Open PostgreSQL › Backups. The schedule is shown above the backup list. Choose Back up now before a large change. Backups cover the schema, data, policies and functions, not Storage files or your app's users.

Questions about PostgreSQL on DASTER

Can I connect with psql from my laptop?

Not yet. The poolers accept connections only from apps hosted on DASTER today. Use the SQL Editor, the API (POST …/backend/sql) or the data API until outside connections open.

What happens when the database is full?

It becomes read-only. Writes are refused with database_storage_full, reads keep working, and you can delete rows or add storage on Settings › Size and limits to make room. The Usage card warns from 80 %.

Does a restore overwrite my data?

No. A restore puts the backup into a new generation of the database. If it fails, the live database is untouched. One restore runs per project at a time.

Which extensions can I use?

pgcrypto, uuid-ossp, citext and hstore, from the Extensions tab.

Is the database private by default?

Tables created on the Tables tab use row-level security and deny client access until you add a policy. The poolers accept only TLS connections with your project's own roles, and you can limit them to address ranges.

In the docs

Next steps