Migrations
The tables are created and upgraded by SQL files this package ships in migrations/, generated by
drizzle-kit from src/schema.ts and applied by Drizzle's migrator. Its journal is in a schema of its own
(agent_runtime_drizzle), apart from the app's.
# at deploy time; reads AGENT_RUNTIME_DATABASE_URL or DATABASE_URL
pnpm exec motoko-store-postgres migrate
pnpm exec motoko-store-postgres checkor await migrate(pool) from code. Run it from the installed package: it reads the SQL files from the
package folder, which a bundle does not carry.
Every lease, storage open and delete checks the database against the migrations this package lists (a lease
and a storage open within their own one statement) and
rejects with SchemaVersionError when the tables are missing, older, or migrated by a newer release.
That check reads no file, so it works in a bundled app. A database a newer release migrated is refused
rather than written to: roll forward instead of back.
Changing the schema: edit src/schema.ts, run pnpm db:generate, and add the new folder's name to
src/shipped.ts. Never edit a released migration.