CLI Flags

Below is the description of the configuration parameters can be passed to the Spanner migration tool CLI flags.

Table of contents
  1. Source Profile
  2. Target Profile

Source Profile

Spanner migration tool accepts the following params for –source-profile, specified as “key1=value1,key2=value,…” pairs:

  • file: Specifies the full path of the file to use for reading source database schema and/or data. This param is optional, and the file can also be piped to stdin, if available locally. If the file is located in Google Cloud Storage (GCS), you can use the following format: file=gs://{bucket_name}/{path/to/file}. Please ensure you have read pemissions to the GCS bucket you would like to use.

  • format: Specifies the format of the file. Supported file formats are dump and csv. This param is also optional, and defaults to dump. This may be extended in future to support other formats such as avro etc.

  • host: Specifies the host name for the source database.

  • user: Specifies the user for the source database.

  • dbName: Specifies the name of the source database. For Cassandra, this corresponds to the keyspace.

  • port: Specifies the port for the source database.

  • password: Specifies the password for the source database.

  • datacenter: Optional flag. Specifies the datacenter for the source database. This parameter is specific to Cassandra source and will be ignored for all other databases.

  • streamingCfg: Optional flag. Specifies the file path for streaming config. Please note that streaming migration is only supported for MySQL and PostgreSQL databases currently. Here is an example of a streamingCfg JSON and how to use it in the CLI.

Target Profile

Spanner migration tool accepts the following options for –target-profile, specified as “key1=value1,key2=value,…” pairs:

  • project: Specifies the name of the Google Cloud Project in which the Spanner instance is present. If the project is not specified, Spanner migration tool will try to fetch the configured project in the gCloud CLI.

This project flag can have different value than the –project flag in the main command. In some cases, you may want to keep the spanner instance in a separate GCP project than the project where all the migration resources are created. This project flag refers to the project in which the Spanner instance is present and –project flag in the main command refers to the project where the tool can create resources (Dataflow jobs, GCS Buckets etc.) for the migration.

  • dbName: Specifies the name of the Spanner database to create. This must be a new database. If dbName is not specified, Spanner migration tool creates a new unique dbName.

  • instance: Specifies the Spanner instance to use. The new database will be created in this instance. If not specified, the tool automatically determines an appropriate instance using gcloud.

  • dialect: Specifies the dialect of Spanner database. By default, Spanner databases are created with GoogleSQL dialect. You can override the same by setting dialect=PostgreSQL in the -target-profile. Learn more about support for PostgreSQL dialect in Cloud Spanner here.

  • defaultTimezone: Specifies the default timezone of the Spanner database. Must be a valid entry from the IANA Time Zone Database. If not specified, the default timezone is not set when creating the Spanner database, and the database will therefore default to America/Los_Angeles (the default timezone for Spanner databases). Note, the default timezone can only be set on an empty Spanner database without any tables; a warning will be logged and this setting will be ignored if the database already includes tables.

  • defaultIdentitySkipRange: Optional flag. Specifies the default SKIP RANGE values to use for IDENTITY columns. Specified as <min>-<max>, where both <min> and <max> are positive integers and <min> must be less than <max>. For example, defaultIdentitySkipRange=10-50. For instructions on setting SKIP RANGE values for individual columns, see here.

  • defaultIdentityStartCounterWith: Optional flag. Specifies the default START COUNTER WITH value to use for IDENTITY columns. This should be a positive integer. For example, defaultIdentityStartCounterWith=1000. For instructions on setting the START COUNTER WITH value for individual columns, see here.