Schema subcommand

This subcommand can be used to perform schema conversion and report on the quality of the conversion. The generated schema mapping file (session.json) can be then further edited using the Spanner migration tool web UI to make custom edits to the destination schema. This session file is then passed to the data subcommand to perform data migration while honoring the defined schema mapping. Spanner migration tool also generates Spanner schema which users can modify manually and use directly as well.

The command below assumes that the open-source version of SMT is being used. For the CLI reference of the gCloud version of SMT, please refer here.

Table of contents
  1. NAME
  2. SYNOPSIS
  3. DESCRIPTION
  4. EXAMPLES
  5. REQUIRED FLAGS
  6. OPTIONAL FLAGS

NAME

./spanner-migration-tool schema - migrate schema from a source database
    to Cloud Spanner

SYNOPSIS

./spanner-migration-tool schema --source=SOURCE [--dry-run]
    [--log-level=LOG_LEVEL] [--prefix=PREFIX]
    [--source-profile=SOURCE_PROFILE] [--target=TARGET]
    [--target-profile=TARGET_PROFILE] [--project=PROJECT] [GCLOUD_WIDE_FLAG ...]

DESCRIPTION

Migrate schema from a source database to Cloud Spanner.

EXAMPLES

To generate schema file for Cloud Spanner GoogleSQL dialect from the source PostgreSQL database using pg_dump:

    $ ./spanner-migration-tool schema --source=postgresql < \
        ~/cart.pg_dump

To do schema migration with direct connection from source database:

    $ ./spanner-migration-tool schema --source=MySQL \
        --source-profile='host=host,port=3306,user=user,password=pwd,dbN\
    ame=db' \
        --target-profile='project=spanner-project,instance=spanner-insta\
    nce' --project='migration-project'

REQUIRED FLAGS

 --source=SOURCE
    Flag for specifying source database (e.g., PostgreSQL, MySQL,
    DynamoDB).

OPTIONAL FLAGS

Detailed description of optional flags can be found here.

 --dry-run
    Flag for generating DDL and schema conversion report without creating a
    Cloud Spanner database.

 --log-level=LOG_LEVEL
    To configure the log level for the execution (INFO, VERBOSE).

 --prefix=PREFIX
    File prefix for generated files.

 --source-profile=SOURCE_PROFILE
    Flag for specifying connection profile for source database (e.g.,
    "file=<path>,format=dump").

 --target=TARGET
    Specifies the target database, defaults to Spanner (accepted values:
    Spanner) (default "Spanner").

 --target-profile=TARGET_PROFILE
    Flag for specifying connection profile for target database (e.g.,
    "dialect=postgresql").

 --project=PROJECT
    Flag for specifying the name of the Google Cloud Project in which the Spanner migration tool
    can create resources required for migration. If the project is not specified, Spanner migration 
    tool will try to fetch the configured project in the gCloud CLI.