Publishing, domains, backups and rollback

Shipping shouldn't be scary. A publish rehearses the migration on a copy of production and verifies the app against it first; production gets only additive schema changes, after a snapshot; the release is the exact bundle you tested in dev. If it goes wrong, one call puts the previous release back.

Publish

versions { "project_id": "…", "action": "diff" }               // what changed since the live release, with the SQL
deploy { "project_id": "…", "dry_run": true }                    // the plan: host, first publish or migration, SQL, workflows
deploy { "project_id": "…", "subdomain": "stillwater" }          // rehearse, verify, snapshot, migrate, publish

From CI or a script, the same is POST /api/dev/v1/projects/<id>/deploy (and /deploy/plan) with a token that has the deploy scope. A deploy takes a few minutes: when it answers "status": "running", call it again to join the same run.

What a publish does

  1. The host is checked first: a subdomain another project serves answers SUBDOMAIN_TAKEN before anything runs.
  2. The migration runs on a copy of production; verify then runs the dev app on that copy, the role matrix and the page walk against real rows. A red report stops here, production untouched (skip_verify skips both).
  3. Production is snapshotted and gets the additive steps only: new tables, columns, indexes, looser constraints. Rows are kept.
  4. Steps that drop or tighten (a column you removed, a new not null) wait: the answer lists them as skipped_destructive, they are held for at least 24 hours, and they run when you decide (allow_destructive: true), after a snapshot. Tell people before you do.
  5. The same content-addressed bundle dev runs is switched in; nothing is built again. Workflows are armed and disarmed as the plan said.
  6. For a while afterwards the platform compares server errors and failed runs with the release before, and routes back on its own if they jump.

Production never gets dev's test rows. The first publish builds a fresh database from db/ and runs only the seed files marked -- @env prod, and so does every later publish (additively). To start production from a copy of dev instead, deploy the first time with first_publish_data: "copy_dev".

Previews per branch

appbricx push <project-id> . --preview            # named after the git branch: feature/teaser → feature-teaser
appbricx push <project-id> . --preview --delete   # when the branch is merged

A preview is a working copy with its own database (a clone of dev), bundle and address, and leaves the dev draft alone. Run it from a pre-push hook or a CI job on every push (APPBRICX_API and APPBRICX_TOKEN set). A preview untouched for 7 days is removed.

Use your own domain

domains { "project_id": "…", "action": "add", "domain": "book.stillwater.studio" }
// the DNS records to set: a CNAME (or A) record for the name and an ownership TXT record
domains { "project_id": "…", "action": "verify", "domain": "book.stillwater.studio" }
// active once both records are right, else DNS_NOT_READY naming what is missing
  • Publish once before adding a domain. DNS can take hours: verify again later.
  • An active domain serves the published app and follows every deploy and rollback; HTTPS is set up for you. Every path is rendered for the domain like on the published address: each page has its own title and head.
  • Make one domain primary (the Routing page, or PATCH /domains/:d { "primary": true }): it is the app's canonical address. The canonical link, og:url, structured data, sitemap.xml and the Sitemap: line of robots.txt name it on every address the app answers on, and pages opened on the published <name>.apps address move there (a permanent redirect, path and query kept). The data API, webhooks, files and other requests to the .apps address keep working there. Without a primary domain every address speaks for itself.
  • The primary domain's www twin (www.example.com for example.com, or the other way round when www is primary) redirects to it unless you set another redirect for it. Other domains serve the app, with the primary as their canonical address.
  • Custom domains depend on your plan (PLAN_REQUIRED otherwise); see pricing.
  • routing moves the production subdomain (set_subdomain, the old address stops at once) or renames the dev address (set_dev_url, the old one redirects).

Backups

  • A database snapshot is taken before every publish and before every agent write on production (sql, edit_rows and the like answer its snapshotId).
  • snapshots { "action": "create", "env": "prod" } takes one by hand; list shows them; download gives a link (about an hour) to the dump.

Roll back

A release

deploys { "project_id": "…", "action": "list" }
deploys { "project_id": "…", "action": "rollback", "deploymentId": "…", "dry_run": true }   // what changes
deploys { "project_id": "…", "action": "rollback", "deploymentId": "…" }

A rollback switches the served release back. The schema is still expanded, so the older code works and the data stays as it is. schema: true also reverses what later releases added and that one doesn't declare, after a snapshot that keeps the values; restore_db: true instead puts production's database back to the snapshot taken when that release was replaced (rows written since are lost).

Data

snapshots { "project_id": "…", "action": "restore", "env": "prod", "id": "…" }
// replaces the whole database; the current state is snapshotted first (undoSnapshotId)

Taking the site down

deploys { "action": "take_down" } lists the hosts that would go dark; dry_run: false takes the site down. Data, releases and domains stay, and deploy brings it back at the same address.

Demo apps that reset every night

Not on this platform yet: deploy accepts demo_reset and only warns. To refresh a public demo, run a scheduled workflow that puts your demo rows back, or restore a snapshot.

Gotchas

  • A restore replaces everything written after the snapshot. It snapshots first, so a restore can be undone, but restore soon and tell your users.
  • A publish refuses while a value is missing that app.config.ts marks required: ["prod"], naming each. Set them with secrets first.
  • Subdomains are first come, first served.
  • A rollback that needs objects production no longer has is refused; restore a snapshot then.

Related