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 [--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

  1. --allow-long-unavailability Allow large schema changes which incur a longer unavailability of the database.
  2. --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).
  3. --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")
  4. -h, --help help for ApplySchema
  5. --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.
  6. --sql stringArray Semicolon-delimited, repeatable SQL commands to apply. Exactly one of --sql|--sql-file is required.
  7. --sql-file string Path to a file containing semicolon-delimited SQL commands to apply. Exactly one of --sql|--sql-file is required.
  8. --uuid strings Optional, comma-delimited, repeatable, explicit UUIDs for migration. If given, must match number of DDL changes.
  9. --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 for the total command (default 1h0m0s)
  2. --server string server to use for connection (required)

SEE ALSO

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