Skip to content

Migration SQL

Migrations execute on the pinned OpenCloud PostgreSQL runtime with a constrained per-app migration role and app schema search path.

Supported patterns

  • tables, indexes, constraints, views, sequences, triggers, and ordinary functions inside the app schema;
  • PostgreSQL built-ins available in the pinned runtime;
  • auth.uid() for user ownership;
  • RLS policy creation and alteration;
  • gen_random_uuid(), JSON/JSONB, arrays, generated expressions, and common scalar/date functions.

Deployments run the complete declared history in a disposable schema before touching the live app schema. This catches runtime-only missing functions, invalid policy expressions, type errors, and ordering assumptions.

Forbidden capabilities

  • role, user, database, tablespace, extension, server, publication, or subscription management;
  • GRANT, REVOKE, COPY, anonymous DO blocks, or SECURITY DEFINER;
  • schema management, role switching, or search-path changes;
  • direct platform, shared, public, or other app schema references;
  • RLS disabling, ownership changes, large-object import/export, or dblink;
  • direct PostgreSQL connections from application code.

Each migration is limited to 2 MiB. Keep IDs lexicographically ordered and never modify or omit an applied migration.

Portability guidance

Prefer documented PostgreSQL core functions. When using a less common expression, reproduce it in a small migration and rely on validate plus the server-side preflight before activation.

Self-hosted infrastructure for agent-built applications.