cmd

command
v0.30.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package main demonstrates running apps in single-app and multi-app modes.

The app connects with its own database login, and its schema and migrations run with a separate migration (owner) login, in a step of their own. Provision both logins once with an admin login (see "Database isolation" in the multiapp README), for example:

go run ./cmd/multiappdb apply --admin-url-env ADMIN_DATABASE_URL \
    --owner sf_owner --app example --role app_example_login \
    --password-env EXAMPLE_DB_PASSWORD

Migrate, with the owner login, as a separate step (in production a one-off task given only the owner's secret):

MIGRATION_DATABASE_URL=postgres://sf_owner@... go run main.go migrate

Then serve, with the app's own login only. Single-app mode (dedicated deployment):

MODE=single MIGRATION_ROLE=sf_owner \
    EXAMPLE_DATABASE_URL=postgres://app_example_login@... go run main.go

Multi-app mode (shared deployment): the same, with MODE=multi.

For local development only, the server can run the migrations itself with the owner login:

IN_PROCESS_MIGRATIONS=1 MIGRATION_DATABASE_URL=postgres://sf_owner@... \
    EXAMPLE_DATABASE_URL=postgres://app_example_login@... go run main.go

or every app can share the owner login, which the database then does not keep apart:

SHARED_DATABASE_LOGIN=1 MIGRATION_DATABASE_URL=postgres://... go run main.go

Then test with:

# Single-app mode:
curl http://localhost:8080/api/info

# Multi-app mode:
curl -H "X-App-ID: example" http://localhost:8080/api/info

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL