Skip to main content

Module setup_schema

Module setup_schema 

Source
Expand description

DDL statements that materialize the _mz_deploy tracking database.

Each entry is executed as its own statement by super::setup::setup. Executing them individually (rather than as one multi-statement batch via batch_execute) avoids Materialize’s rejection of DDL inside the implicit transaction block that a simple multi-statement query creates.

Every statement is idempotent — setup is the only command that writes to _mz_deploy, and it can be re-run any number of times to bring an existing installation up to the current set of objects. The initial tables.version row is seeded separately by super::setup::setup with a pre-check, since there is no INSERT IF NOT EXISTS form in Materialize.

Order matters: tables must exist before the indexes and views that reference them.

EXPECTED_OBJECTS MUST stay in sync with the CREATE statements here; a unit test in this module guards the invariant.

Constants§

EXPECTED_OBJECTS 🔒
The known set of objects that _mz_deploy contains after a successful setup. Used by verify() to check whether setup has been run.
SETUP_STATEMENTS 🔒
All DDL statements required to initialize _mz_deploy from a clean database, and safe to re-run against an existing one. The _mz_deploy database itself is created separately by super::setup::setup immediately before iterating these.