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:

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

Options

  1. --allow-long-unavailability Deprecated and has no effect.
  2. --batch-size int How many queries to batch together. Only applicable when all queries are CREATE TABLE|VIEW
  3. --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).
  4. --ddl-strategy string Online DDL strategy, compatible with @@ddl_strategy session variable (examples: 'gh-ost', 'pt-osc', 'gh-ost --max-load=Threads_running=100'. (default "direct")
  5. -h, --help help for ApplySchema
  6. --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.
  7. --sql stringArray Semicolon-delimited, repeatable SQL commands to apply. Exactly one of --sql|--sql-file is required.
  8. --sql-file string Path to a file containing semicolon-delimited SQL commands to apply. Exactly one of --sql|--sql-file is required.
  9. --uuid strings Optional, comma-delimited, repeatable, explicit UUIDs for migration. If given, must match number of DDL changes.
  10. --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

  1. --action_timeout duration timeout to use for the command (default 1h0m0s)
  2. --compact use compact format for otherwise verbose outputs
  3. --server string server to use for the connection (required)

SEE ALSO

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