{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/google-firebase/json-schema/google-firebase-migrate-schema-request-schema.json",
  "title": "MigrateSchemaRequest",
  "description": "Request message for `MigrateSchema`. Next tag: 7",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/google-firebase-firebasedataconnect-projects-api-openapi.yml#/components/schemas/MigrateSchemaRequest",
  "properties": {
    "executionMode": {
      "type": "string",
      "enum": [
        "EXECUTION_MODE_UNSPECIFIED",
        "EXECUTE_AND_RECORD",
        "EXECUTE_ONLY",
        "RECORD_ONLY"
      ],
      "description": "Optional. Execution mode controlling DDL execution and ledger recording. Defaults to EXECUTE_AND_RECORD."
    },
    "validateOnly": {
      "description": "Optional. When true, runs preflight validation (syntax, applied-step immutability, sequence ordering, CONCURRENTLY isolation, and SAVEPOINT catalog checks) without committing mutations to the database.",
      "type": "boolean"
    },
    "migrationSteps": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MigrationStep"
      },
      "description": "Required. Ordered migration steps from `./sql/migrations/` (or a single ad-hoc step). Backend compares submitted versions against `firebasesql.schema_migrations`: already-applied steps are verified for SQL immutability and skipped, while unapplied steps (`version > MAX(applied_version)`) are executed. All unapplied transactional steps in a single request execute atomically within one database transaction (BEGIN ... COMMIT): either every unapplied step commits and is recorded in the ledger, or the entire request rolls back. An unapplied step containing CREATE INDEX CONCURRENTLY or DROP INDEX CONCURRENTLY cannot be mixed with other unapplied steps and must be the sole unapplied step executed in the request."
    }
  },
  "type": "object",
  "$defs": {
    "MigrationStep": {
      "properties": {
        "sql": {
          "type": "string",
          "description": "Required. Raw multi-statement SQL script. The backend splits it into individual statements before execution; callers do not pre-split. Required whenever the request executes or records DDL, which is every publicly available execution mode; omitting it returns INVALID_ARGUMENT."
        },
        "version": {
          "type": "string",
          "description": "Optional. Monotonic 14-digit UTC timestamp (YYYYMMDDHHMMSS), matching the timestamp prefix of the developer's migration filename. Constrained to `^[0-9]{14}$`. - When specified (file migrations): If `version` is already recorded in `firebasesql.schema_migrations`, the backend verifies that `sql` matches the recorded statements and skips execution. If `version` is unapplied, the backend validates `version > MAX(applied_version)` and records the value unchanged, so the ledger row and the on-disk filename stay identical. - When omitted (Console/ad-hoc): Backend auto-generates a 14-digit UTC timestamp."
        },
        "name": {
          "description": "Optional. Descriptive migration label (e.g. \"create_accounts_table\"). If omitted, defaults to \"adhoc\".",
          "type": "string"
        }
      },
      "type": "object",
      "description": "An individual unit of migration work. Next tag: 4"
    }
  }
}