Deploy and retire versions
Plan against a database, stage a candidate, and activate it. Clients bind to an active package version.
Connect as a database administrator
Use the endpoint shown on the database’s console page. In a Bash terminal, enter the full db.<username>.<password> tenant credential when prompted. The initial root credential can publish a package. A delegated database user needs schema permissions. The organization login belongs to the console.
export APPDB_DB=your-database-name
export APPDB_ENDPOINT="https://${APPDB_DB}.db.appdb.cloud"
read -rsp 'Database credential: ' APPDB_TOKEN
echo
export APPDB_TOKENInstall the CLI tools and save notebook.dbl in your working directory.
Plan and stage
appdb admin "$APPDB_ENDPOINT" plan-package initial notebook.dbl
appdb admin "$APPDB_ENDPOINT" submit-package initial notebook.dblA plan checks the proposed change against the current database. Submit stages one candidate and prints version=… contract=… generation=… staged=true. Keep the submitted version and generation. Staged code becomes callable when you activate it.
| Mode | When to use it |
|---|---|
initial | First package on an empty database. |
indexes | Index declarations or function-only changes. |
constraints | Checks, foreign keys, uniqueness, or collection bounds. |
fields | Supported changes to the fields of existing tables. |
tables | Supported changes to the set of tables. |
Choose the mode that describes your update. Planning can reject incompatible changes or dependencies on indexes that are not ready. Keep the previous version serving while you resolve the diagnostic.
Activate and bind clients
read -rp 'Submitted version: ' APPDB_VERSION
read -rp 'Submitted generation: ' APPDB_GENERATION
export APPDB_VERSION
appdb admin "$APPDB_ENDPOINT" activate-package "$APPDB_VERSION" "$APPDB_GENERATION"
appdb admin "$APPDB_ENDPOINT" versionsActivation atomically makes the candidate current. Deploy clients generated from its source and configure them with its exact version. Older supported clients can continue using their own versions. A stale generation means another lifecycle change won the race. Inspect appdb admin "$APPDB_ENDPOINT" schema and versions before choosing the next operation.
Make the first call from Python
Generate the client from the activated source in an empty working directory containing notebook.dbl. This one-time test inserts book 1 and note 1 into a fresh notebook database. It prints First entry and ['First entry'].
python3 -m venv .venv
. .venv/bin/activate
python -m pip install h2
dbl generate --lang python --out generated notebook.dblimport asyncio
import os
import ssl
from client import Client
async def main():
db = await Client.connect(
host=f"{os.environ['APPDB_DB']}.db.appdb.cloud",
port=443,
credential=os.environ["APPDB_TOKEN"],
version=os.environ["APPDB_VERSION"],
ca_file=ssl.get_default_verify_paths().cafile,
)
try:
await db.notebook_create_book(1, "field-notes")
await db.notebook_add(1, 1, "First entry")
print(await db.notebook_lookup(1))
print(await db.notebook_page(1, 0, 8))
finally:
await db.close()
asyncio.run(main())python generated/demo.pyUse a dedicated database user with the necessary grants for server-side applications. See Identity and permissions for application tokens, browser clients, and role assignment.
Withdraw a staged candidate
Run this in place of activation when the staged package should never become current. Use the staged version and its generation. Withdrawal frees the staging slot; the current head keeps serving.
appdb admin "$APPDB_ENDPOINT" withdraw-package "$APPDB_VERSION" "$APPDB_GENERATION"Retire an old version
After activating a successor, move client traffic to it. versions lists supported versions with a sequence and connection count. schema reports the current deployment generation. Manual retirement accepts the oldest supported predecessor. The current head needs an active successor first.
appdb admin "$APPDB_ENDPOINT" versions
appdb admin "$APPDB_ENDPOINT" schema
read -rp 'Old version to retire: ' OLD_VERSION
read -rp 'Current deployment generation: ' GENERATION
appdb admin "$APPDB_ENDPOINT" retire-version "$OLD_VERSION" "$GENERATION"
appdb admin "$APPDB_ENDPOINT" versionsFor ordinary hosted packages the default automatic policy retires superseded versions after 30 idle minutes or at most 24 hours from successor activation. A reconnect can reset the idle period. New bindings to an expired or retired version fail, so update clients before the deadline.