ApplySchema

vtctldclient ApplySchema #

Applies the schema change to the specified keyspace on every primary, running in parallel on all shards. The changes are then propagated to replicas via replication.

Synopsis #

Applies the schema change to the specified keyspace on every primary, running in parallel on all shards. The changes are then propagated to replicas via replication.

If --allow-long-unavailability is set, schema changes affecting a large number of rows (and possibly incurring a longer period of unavailability) will not be rejected. --ddl-strategy is used to instruct migrations via vreplication, gh-ost or pt-osc with optional parameters. --migration-context allows the user to specify a custom migration context for online DDL migrations. If --skip-preflight, SQL goes directly to shards without going through sanity checks.

The --uuid and --sql flags are repeatable, so they can be passed multiple times to build a list of values. For --uuid, this is used like "--uuid $first_uuid --uuid $second_uuid". For --sql, semi-colons and repeated values may be mixed, for example:

ApplySchema --sql "CREATE TABLE my_table; CREATE TABLE my_other_table"
ApplySchema --sql "CREATE TABLE my_table" --sql "CREATE TABLE my_other_table"
vtctldclient ApplySchema [--allow-long-unavailability] [--ddl-strategy <strategy>] [--uuid <uuid> ...] [--migration-context <context>] [--wait-replicas-timeout <duration>] [--caller-id <caller_id>] {--sql-file <file> | --sql <sql>} <keyspace>

Options #

      --allow-long-unavailability        Allow large schema changes which incur a longer unavailability of the database.
      --caller-id string                 Effective caller ID used for the operation and should map to an ACL name which grants this identity the necessary permissions to perform the operation (this is only necessary when strict table ACLs are used).
      --ddl-strategy string              Online DDL strategy, compatible with @@ddl_strategy session variable (examples: 'vitess', 'pt-osc', 'gh-ost --max-load=Threads_running=100'. (default "direct")
  -h, --help                             help for ApplySchema
      --migration-context string         For Online DDL, optionally supply a custom unique string used as context for the migration(s) in this command. By default a unique context is auto-generated by Vitess.
      --sql stringArray                  Semicolon-delimited, repeatable SQL commands to apply. Exactly one of --sql|--sql-file is required.
      --sql-file string                  Path to a file containing semicolon-delimited SQL commands to apply. Exactly one of --sql|--sql-file is required.
      --uuid strings                     Optional, comma-delimited, repeatable, explicit UUIDs for migration. If given, must match number of DDL changes.
      --wait-replicas-timeout duration   Amount of time to wait for replicas to receive the schema change via replication. (default 10s)

Options inherited from parent commands #

      --action_timeout duration   timeout for the total command (default 1h0m0s)
      --server string             server to use for connection (required)

SEE ALSO #

  • vtctldclient - Executes a cluster management command on the remote vtctld server.