github.com/scraniel/migrate@v0.0.0-20230320185700-339088f36cee/database/spanner/README.md (about)

     1  # Google Cloud Spanner
     2  
     3  ## Usage
     4  
     5  See [Google Spanner Documentation](https://cloud.google.com/spanner/docs) for
     6  more details.
     7  
     8  The DSN must be given in the following format.
     9  
    10  `spanner://projects/{projectId}/instances/{instanceId}/databases/{databaseName}?param=true`
    11  
    12  as described in [README.md#database-urls](../../README.md#database-urls)
    13  
    14  | Param | WithInstance Config | Description |
    15  | ----- | ------------------- | ----------- |
    16  | `x-migrations-table` | `MigrationsTable` | Name of the migrations table |
    17  | `x-clean-statements` | `CleanStatements` | Whether to parse and clean DDL statements before running migration towards Spanner (Required for comments and multiple statements) |
    18  | `url` | `DatabaseName` | The full path to the Spanner database resource. If provided as part of `Config` it must not contain a scheme or query string to match the format `projects/{projectId}/instances/{instanceId}/databases/{databaseName}`|
    19  | `projectId` || The Google Cloud Platform project id
    20  | `instanceId` || The id of the instance running Spanner
    21  | `databaseName` || The name of the Spanner database
    22  
    23  > **Note:** Google Cloud Spanner migrations can take a considerable amount of 
    24  > time. The migrations provided as part of the example take about 6 minutes to 
    25  > run on a small instance.
    26  >
    27  > ```log
    28  > 1481574547/u create_users_table (21.354507597s)
    29  > 1496539702/u add_city_to_users (41.647359754s)
    30  > 1496601752/u add_index_on_user_emails (2m12.155787369s)
    31  > 1496602638/u create_books_table (2m30.77299181s)
    32  
    33  ## DDL with comments
    34  
    35  At the moment the GCP Spanner backed does not seem to allow for comments (See https://issuetracker.google.com/issues/159730604)
    36  so in order to be able to use migration with DDL containing comments `x-clean-stamements` is required
    37  
    38  ## Multiple statements
    39  
    40  In order to be able to use more than 1 DDL statement in the same migration file, the file has to be parsed and therefore the `x-clean-statements` flag is required
    41  
    42  ## Testing
    43  
    44  To unit test the `spanner` driver, `SPANNER_DATABASE` needs to be set. You'll
    45  need to sign-up to Google Cloud Platform (GCP) and have a running Spanner
    46  instance since it is not possible to run Google Spanner outside GCP.