Creating Migration Scripts

A script is the atomic, versioned, content-hashed unit of change. This page covers authorship, the target-resolution model, type classification, versioning semantics, and dependency declaration.

Authorship Paths

Inline

Paste or write SQL / MongoDB shell into the editor. As you type, type classification runs live and constrains the target picker; a name and content are the only fields required to persist. Target instance and database are resolved through catalog introspection (below) and may be deferred.

Pull from provider

With a configured repository/storage source, scan the source's path for files matching its glob and import a subset; each imported file becomes a Draft script with the filename as its name. Providers: GitHub, GitLab, Bitbucket, Azure DevOps, S3, Azure Blob, GCS, Dropbox. See Environments & Repository Sources.

Type Classification & Target Filtering

Content is classified into SQL, MongoDB, or Unknown by pattern match, DDL/DML/dialect syntax (PL/pgSQL, T-SQL, PL/SQL) vs. shell operators (db.collection.*, aggregation pipeline stages, ObjectId). Classification is reactive: flipping content from SQL to Mongo clears an incompatible selected instance. The instance picker is filtered to compatible targets (SQL → PostgreSQL/MySQL/MSSQL/Oracle; Mongo → MongoDB); Unknown shows all.

Target Resolution via Catalog Introspection

The target-database dropdown is populated by querying the selected instance's system catalogs in real time, pg_database, information_schema.schemata, sys.databases, admin.listDatabases(), or v$pdbs by dialect, so you select from what actually exists on the instance, not a free-text guess.

Author-Set Properties

Only name and content are required. Target connection, target database, environment, and release membership may be left unset and bound later, a script can be drafted and even sent for approval before its execution target is decided; these fields are revalidated at execution time.

PropertyRequiredNotes
NameYesStable, descriptive identifier, e.g. alter-orders-add-status-column.
ContentYesSQL (DDL/DML) or MongoDB shell operations.
TypeYesRelease (promotes through environments in a release) or Ad-hoc (executes independently).
Database TypeYesTarget engine; drives validation and execution behavior.
Target InstanceNoDeduplicated, type-filtered instance list (host:port).
Target DatabaseNoCatalog-introspected against the selected instance.
TagsNoFree-form labels for filtering and grouping.
DependenciesNoPredecessor scripts, resolved topologically at run time.

System-Managed Properties

PropertySemantics
Approval StatusDraft → Pending → Approved | Rejected → Executed.
VersionInteger, starts at 1, increments on every content edit.
Content HashSHA-256 of content; binds reviewed bytes to executed bytes and gates approval invalidation.
Created / Updated At, Created ByProvenance timestamps and author.

Edit Semantics & Approval Invalidation

Editing content bumps the version and recomputes the hash. If the script was Approved, the hash change resets it to Draft, approval is pinned to exact bytes, so a re-review is mandatory before the mutated script can run. This is the mechanism that guarantees the executed version is the reviewed version, not a safety suggestion.

Dependencies

Declaring "B depends on A" constrains ordering: A must execute successfully before B is attempted. Dependencies are added via search and shown as removable badges. At execution, standalone or release-scoped, the engine builds a DAG, topologically sorts, executes in order, and halts the frontier on first failure (dependents unattempted).

Cycle Detection

A cycle (A→B→C→A) is detected and rejected at save; the graph must be acyclic to persist.

Canonical patterns

Authoring Discipline

Lifecycle

  1. Create, author content + properties. Status: Draft.
  2. Request Approval, submit. Status: Pending.
  3. Review, reviewer decides. Status: Approved | Rejected.
  4. Resubmit (if rejected), edit, version bumps, back to Pending.
  5. Compose, add approved Release-type scripts to a release.
  6. Execute, run against resolved target. Status: Executed.