version unknown

atlas-spanner

ariga@ariga⭐ 8.9k stars· last commit 5d ago· 256 open issues

Google Cloud Spanner specifics for Atlas: the extended build and login, URLs and Application Default Credentials, GoogleSQL and PostgreSQL dialects, the emulator dev database and what it lacks, `-- atlas:txmode none` in every migration file, partial failures and long-running schema changes (index backfills, validations, Google's batch limits), what Spanner cannot change in place (primary keys, interleaving, column types, renames), objects Atlas leaves out or plans wrongly (identity columns, NOT ENFORCED foreign keys, interleaved indexes, change streams, database options), hotspot-free keys and bit-reversed sequences, named schemas, roles and grants, migration tests in place of schema tests, mutation limits and batched backfills, and custom lint rules. Use with the atlas skill whenever Atlas manages a Spanner database.

Choose how to use this skill

You do not need every option. Choose the path your AI client supports. The stable page stays the same; versioned files are immutable.

1. Native installer

This listing has no registered native installer command. Use the complete package or source fallback below, depending on what your client supports.

Do not guess an installer command or replace an existing version without reviewing the diff.

2. Complete package recommended

Download the ZIP when available. It includes SKILL.md plus the references, security notes and version metadata.

No complete ProSkills package is published for this listing yet.

3. Prompt-only

Copy the prompt above when the agent can read the stable page or when you want to adopt the workflow without installing a skill.

Need only the instruction file?

Download SKILL.md only if your client requires a single file. The complete ZIP is safer for a full installation because it preserves the references and release context.

No path installs or executes anything by itself. Your agent still needs access to the project files. Before updating, compare the installed version and review the diff.

8.1/10
Verified
Oct 12, 2026

// RATINGS

⭐GitHub Stars
⭐⭐⭐⭐⭐ 8.9k on GitHubGitHub ↗

Very popular

🟢ProSkills ScoreAI Verified
8.1/10
📍

Not yet listed on ClawHub or SkillsMP

// README

Atlas - Manage Your Database Schema as Code

Twitter Discord

Atlas is a language-agnostic tool for managing and migrating database schemas using modern DevOps principles. It offers two workflows:

  • Declarative: Similar to Terraform, Atlas compares the current state of the database to the desired state, as defined in an [HCL], [SQL], or [ORM] schema. Based on this comparison, it generates and executes a migration plan to transition the database to its desired state.

  • Versioned: Unlike other tools, Atlas automatically plans schema migrations for you. Users can describe their desired database schema in [HCL], [SQL], or their chosen [ORM], and by utilizing Atlas, they can plan, lint, and apply the necessary migrations to the database.

Supported Databases

PostgreSQL · MySQL · MariaDB · SQL Server · SQLite · ClickHouse · Redshift · Oracle · Snowflake · CockroachDB · TiDB · Databricks · Spanner · Aurora DSQL · Azure Fabric

Installation

macOS + Linux:

curl -sSf https://atlasgo.sh | sh

Homebrew:

brew install ariga/tap/atlas

Docker:

docker pull arigaio/atlas

NPM:

npx @ariga/atlas

See installation docs for all platforms.

Install the skills

Claude Code:

claude plugin marketplace add ariga/atlas
claude plugin install atlas@ariga

Codex, Cursor, or GitHub Copilot, from the root of your repository:

npx skills add ariga/atlas -a codex -y   # or: -a cursor, -a github-copilot

[!NOTE] The Atlas website has the most up-to-date version of these skills: they are maintained there and copied to skills/ from time to time.

Key Features

Getting Started

Get started with Atlas by following the Getting Started docs.

Inspect an existing database schema:

atlas schema inspect -u "postgres://localhost:5432/mydb"

Apply your desired schema to the database:

atlas schema apply \
  --url "postgres://localhost:5432/mydb" \
  --to file://schema.hcl \
  --dev-url "docker://postgres/16/dev"

📖 Getting Started docs

Contributing

We maintain a lot of open source code, including the Atlas core engine. For some projects, including this one, we don't accept public pull requests. We know that's disappointing if you came here to send a fix, so here's the reasoning.

Atlas runs in CI and deployment pipelines and connects to production databases with credentials that can change them. That's a high responsibility, and every decision about how we build Atlas starts from it. If a bad commit ever shipped in Atlas, it would run with those credentials in every pipeline that pulled the release.

Since mid-2025, several popular open source projects have been hit by supply chain attacks that started the same way: a pull request from a stranger. Nobody had to merge anything. Opening the pull request was enough to start a chain that ended with malicious releases published under the project's name. These are strong teams, and it still happened to them. We decided to remove the path instead of relying on never making a mistake.

Every change to Atlas comes from our team, goes through a workflow we can't enforce on outside contributors, and is tested on our e2e and cloud environments for backward compatibility, regressions and performance before it's released.

None of this changes what's open. The code here is yours to read, fork and build on. And if something is broken or missing, please tell us:

Atlas is built to make database changes safe, predictable and secure. We hold changes to Atlas itself to the same standard.

Migration Linting

Atlas ships with 50+ built-in analyzers that review your migration files and catch issues before they reach production. Analyzers detect [destructive chan

// HOW IT'S BUILT

// FILES

9 files shipped with this skill. Inline text is the catalog copy. The upstream link is the source repository.

  • skills/atlas-spanner/SKILL.md17 KB1953f3831cb6upstream ↗
    ---
    name: atlas-spanner
    description: "Google Cloud Spanner specifics for Atlas: the extended build and login, URLs and Application Default Credentials, GoogleSQL and PostgreSQL dialects, the emulator dev database and what it lacks, `-- atlas:txmode none` in every migration file, partial failures and long-running schema changes (index backfills, validations, Google's batch limits), what Spanner cannot change in place (primary keys, interleaving, column types, renames), objects Atlas leaves out or plans differently (identity columns, NOT ENFORCED foreign keys, interleaved indexes, change streams, database options), hotspot-free keys and bit-reversed sequences, named schemas, roles and grants, migration tests in place of schema tests, mutation limits and batched backfills, and custom lint rules. Use with the atlas skill whenever Atlas manages a Spanner database."
    ---
    
    # Atlas for Spanner
    
    What is specific to Google Cloud Spanner when Atlas manages the schema. The `atlas` skill covers the
    workflows and commands; this skill covers the rules, edge cases, and answers that differ on Spanner. It
    covers both dialects, GoogleSQL and PostgreSQL. Behavior was checked against the Spanner emulator
    1.5.58 and Google's Spanner documentation.
    
    ## Files
    
    This skill is `SKILL.md` plus seven reference files under `references/`, each served at
    `https://atlasgo.io/skills/atlas-spanner/references/<name>`. Read a reference when the task needs it:
    
    | File | Read it for |
    |------|-------------|
    | `references/dev-database.md` | Scope and named schemas, `docker://spanner` and `docker://spannerpg`, what the emulator lacks, your own dev database on a real instance, URLs, credentials, and IAM, running an emulator by hand |
    | `references/objects.md` | What Atlas leaves out or plans differently, keys and hotspots, interleaving, type changes, indexes, foreign keys, checks and generated columns, sequences, views, change streams, TTL, named schemas, Enterprise features, the PostgreSQL dialect |
    | `references/hcl.md` | Writing the schema in HCL: HCL or SQL, `STRING(MAX)`, generated columns and options, `interleave`, indexes, sequences, views, change streams, locality groups and placements, property graphs |
    | `references/migrations.md` | `-- atlas:txmode none`, partial failures and recovery, long-running changes and Google's limits, lint on Spanner, dependent objects, changes to write by hand, renames, data changes and mutation limits, the revisions table, baselines |
    | `references/security.md` | Database roles and grants, why they need a real Spanner dev database, `DEFINER` views, IAM bindings outside Atlas |
    | `references/testing.md` | Testing every change with migration tests, testing a declarative schema, what to seed, matching errors, CI |
    | `references/custom-rules.md` | Writing a custom lint rule in the HCL rule language: what Spanner objects expose, and tested rules for hotspot keys and indexes |
    
    ## Requires
    
    The `atlas` skill, installed next to this one (`../atlas/SKILL.md`). If it is missing, download
    https://atlasgo.io/skills/atlas/SKILL.md to `../atlas/SKILL.md` and each reference file listed in its
    Files section to `../atlas/references/<name>`.
    
    ## Rules
    
    1. The Spanner driver ships in the extended build of Atlas and needs a login. If a command fails with
       `The spanner driver is available only as custom build`, install that build:
       `curl -sSf https://atlasgo.sh | ATLAS_FLAVOR="spanner" sh`, or use the `arigaio/atlas:latest-extended`
       image. Check the login with `atlas whoami`. If it shows no login, ask the user to run `atlas login`:
       logged out, every command that connects to Spanner aborts with
       `The spanner driver is available only to Atlas Pro users`. A user without an account can start a free
       trial with `atlas login`.
    2. URLs and scope (`references/dev-database.md`):
       - The URL is `spanner://projects/<project>/instances/<instance>/databases/<database>`. It carries no
         credentials: Atlas uses Application Default Credentials (`gcloud auth application-default login`, or
         the CI runner's service account).
       - The URL covers the whole database: the default schema (`schema "default"` in HCL, `public` in the
         PostgreSQL dialect) and every named schema. A named schema the desired state leaves out is planned
         for a drop: declare it, or limit the run with `schemas`, `--schema`, or `exclude`.
       - `migrate apply` keeps its revisions table in the named schema `atlas_schema_revisions`, which a
         declarative plan on the same database drops unless excluded.
    3. The dev database is the emulator: `docker://spanner/<version>` for GoogleSQL, or
       `docker://spannerpg/<version>` for the PostgreSQL dialect. Pin a release, such as `1.5.58`: `latest` is
       whatever the machine pulled last. The emulator ignores roles and grants, treats placements as no-ops,
       loses some locality group and vector index options, and does not enforce mutation limits. For roles
       and grants, point `dev` at an empty database on a real Spanner instance. Never point `dev` at a real
       environment's database.
    4. Every migration file starts with `-- atlas:txmode none`. `atlas migrate diff` writes it, but
       `atlas migrate new` does not, and a hand-written file without it fails on the target with
       `cannot execute DDL as part of a transaction`. `migrate lint` and `migrate validate` miss it;
       `migrate test` catches it. `atlas schema clean` and `atlas schema test` fail with the same error on
       Spanner: reset a database by applying an empty schema, and test with migration tests (Rule 12).
    5. Spanner has no transactional DDL, and Atlas sends one statement at a time, each its own schema change.
       A file or a plan that fails halfway stays half applied. To recover, fix the failed statement and the
       ones after it and run `atlas migrate hash`, or undo the applied statements with `atlas migrate down`.
       Statements that backfill or validate every row (`CREATE INDEX` on a populated table, `NOT NULL`, a
       shorter `STRING(n)`, a new foreign key or check, a stored generated column) run from minutes to
       hours: keep them in small files of their own. Google advises at most 10 of them per batch and at
       most 3 new backfilled indexes a day. Set the `if_not_exists` diff policy, so a rerun after a dead job
       skips a statement Spanner finished (`references/migrations.md`).
    6. Changes Spanner cannot make in place, each a new column or table, a copy, and a later drop
       (`references/objects.md`):
       - A primary key: planning fails with `the keys of a table cannot change after table creation`.
       - Interleaving is permanent: adding or removing it on an existing table plans no change at all.
       - A type change other than a new length or a conversion between `STRING` and `BYTES`: planning fails
         with `Cannot change type of column`.
       - A new `NOT NULL` column needs a `DEFAULT`, or planning fails with `Cannot add NOT NULL column`.
       - A renamed table is planned as a drop and a create: write `ALTER TABLE ... RENAME TO ...` by hand.
         Columns cannot be renamed.
    7. Read every plan against the schema change: Atlas plans these without an error
       (`references/objects.md`, What Atlas Leaves Out):
       - Identity columns become a plain `INT64` without a generator, and a table without a primary key gets
         a plain `rowid` key. Declare keys, and generate `INT64` keys from a named bit-reversed sequence:
         `DEFAULT (GET_NEXT_SEQUENCE_VALUE(SEQUENCE OrderSeq))`.
       - `NOT ENFORCED` foreign keys become enforced, and interleaved indexes become global indexes. Write
         both by hand.
       - Database options and synonyms are left out. Write them by hand.
       - A change to a change stream drops and recreates it, which deletes its change records. Write
         `ALTER CHANGE STREAM` by hand, and flag `DROP CHANGE STREAM` with a `statement` lint rule.
       - Removing a column together with the index, `STORING` list, or view that uses it plans the
         `DROP COLUMN` first, which Spanner rejects. `migrate diff` writes the file anyway; `migrate lint`
         fails on it. Move the dependent change first and run `atlas migrate hash`
         (`references/migrations.md`, Dependent Objects).
       - A table interleaved with `INTERLEAVE IN`, without `PARENT`, breaks inspection, and a sequence in a
         named schema breaks planning.
    8. Keys: never start a primary key or a frequently written index with a value that only grows, such as a
       timestamp, a commit timestamp, or an id the application increments. All new rows land on one split.
       Use a UUID version 4 (`GENERATE_UUID()`, or the `UUID` type with `NEW_UUID()`) or a bit-reversed
       sequence, and enforce it with the custom rules in `references/custom-rules.md`.
    9. HCL (`references/hcl.md`): name files `*.sp.hcl`. Write `sql("STRING(MAX)")`, since `STRING(MAX)` is
       not an HCL type. Always set `type = IN_PARENT` in an `interleave` block: without it Atlas writes
       invalid DDL. A primary key with a descending part plans only from SQL: in HCL it plans
       `PRIMARY KEY ()`. There is no `data` block, `renamed_from`, or identity column. Declare vector indexes,
       locality groups, and placements in HCL: a SQL schema loses their options on the emulator.
    10. Roles and grants (`references/security.md`): enable them with
        `mode { roles = true, permissions = true }`, and plan them on a dev database on a real Spanner
        instance. Declare every grantee as a `role`: Spanner has no database users, and the `user` block plans
        nothing. Which IAM principals may act as a role is an IAM binding outside Atlas.
    11. Data changes: one DML statement makes up to 80,000 mutations, counting index entries, and the emulator
        does not enforce it. Backfill large tables in batches with `atlas script loop`, or with Partitioned
        DML outside Atlas. Seed rows go in migration files: there is no `data` block on Spanner
        (`references/migrations.md`, Data Changes).
    12. Test every change before reporting it done, as a habit. Run `atlas schema validate`, lint the change
        (`atlas migrate lint`, or the plan of `atlas schema apply --dry-run`), then write `test "migrate"`
        cases: `atlas schema test` does not run on Spanner.
        Seed rows for each change that validates data: `NULL`s before `NOT NULL`, long values before a
        shorter `STRING(n)`, duplicates and two `NULL`s before a unique index, orphans before a foreign key.
        Run them with `atlas migrate test`. A declarative project tests through a throwaway migration
        directory (`references/testing.md`).
    13. When no built-in analyzer covers a check, write a custom lint rule in the HCL rule language, and do
        the same for a convention the user states. Spanner has no analyzers of its own, so these rules carry
        the Spanner checks, such as hotspot keys (`references/custom-rules.md`).
    14. PostgreSQL dialect (`references/objects.md`, PostgreSQL Dialect): plan on `docker://spannerpg/<version>`.
        A TTL breaks planning, and a `spanner.commit_timestamp` column breaks every plan after the first.
        `numeric`, `jsonb`, and `float4` columns cannot be keys or be indexed.
    
    ## Quick Answers
    
    | Question | Answer |
    |----------|--------|
    | A local Spanner database to apply migrations to | `atlas tool docker --url "docker://spanner/1.5.58" --name my-spanner` prints its URL; `atlas tool docker kill --name my-spanner` stops it (`references/dev-database.md`) |
    | `The spanner driver is available only as custom build` | Install the extended build: `curl -sSf https://atlasgo.sh \| ATLAS_FLAVOR="spanner" sh` (Rule 1) |
    | `The spanner driver is available only to Atlas Pro users` | Ask the user to run `atlas login` (Rule 1) |
    | `credentials: could not find default credentials` | Run `gcloud auth application-default login`, or give the runner a service account (`references/dev-database.md`) |
    | `cannot execute DDL as part of a transaction` from `migrate apply` | Add `-- atlas:txmode none` at the top of the file and run `atlas migrate hash` (`references/migrations.md`) |
    | `cannot execute DDL as part of a transaction` from `schema test` or `schema clean` | Neither runs on Spanner: write migration tests, and reset with an empty schema (Rule 4) |
    | `the keys of a table cannot change after table creation` | Create a new table with the new key, copy the rows, then drop the old one (`references/objects.md`) |
    | Adding or removing `INTERLEAVE IN PARENT` plans no change | Interleaving is permanent: create a new table and copy the rows (`references/objects.md`, Interleaving) |
    | ``Cannot change type of column `X` from `INT64` to `STRING` `` | Add a new column, backfill it, and drop the old one later (`references/objects.md`) |
    | `Cannot add NOT NULL column ... to existing table` | Give the new column a `DEFAULT` (`references/objects.md`) |
    | `Cannot specify a null value for column` when a column becomes `NOT NULL` | Backfill the `NULL` rows first: `ALTER COLUMN` does not use the default (`references/objects.md`) |
    | `Reducing the length of column ... is not allowed` | Shorten the longer values first; lint does not report this change (`references/objects.md`) |
    | `Cannot drop column ... because it is used by index`, or `on which there are dependent views` | Move the `DROP INDEX` or the view change above the `DROP COLUMN` (`references/migrations.md`, Dependent Objects) |
    | `Requested change to key column ... could not be made` | Interleaved children inherit the key column, so it cannot change (`references/objects.md`) |
    | `Scan error on column index 3, name "on_delete_action"` | A table uses `INTERLEAVE IN` without `PARENT`: convert it with `ALTER TABLE ... SET INTERLEAVE IN PARENT ...` through `gcloud` (`references/objects.md`, Interleaving) |
    | `Duplicate name in schema` or `Duplicate column name` on a rerun | The statement finished before the job died: set the `if_not_exists` policy, or remove the statement (`references/migrations.md`) |
    | A plan drops `atlas_schema_revisions` or another named schema | The URL covers every schema: declare it, or exclude it (`references/dev-database.md`, Scope) |
    | An identity column, a `NOT ENFORCED` foreign key, or an interleaved index is missing from the plan | Atlas leaves those clauses out: use a sequence, or write them by hand (`references/objects.md`) |
    | A change stream is dropped and recreated | Write `ALTER CHANGE STREAM ... SET OPTIONS` or `SET FOR` by hand (`references/migrations.md`) |
    | A renamed table shows up as a drop and a create | Write `ALTER TABLE Old RENAME TO New, ADD SYNONYM Old` by hand, after `-- atlas:nolint DS102 BC103`; in the declarative workflow, edit the plan with `schema apply --edit` (`references/migrations.md`, Renames) |
    | `an error is expected, but none occurred` from a `catch` on a `SELECT` | `catch` does not see query errors on Spanner: check with `exec` and `output` over `INFORMATION_SCHEMA` (`references/testing.md`, Matching Errors) |
    | `Drop sequence "X": ... Sequence not found` | The sequence is in a named schema: keep sequences in the default schema (`references/objects.md`) |
    | `There is no type named "MAX"` | Write `sql("STRING(MAX)")` (`references/hcl.md`) |
    | `Syntax error ... Expecting 'IN'` on an `INTERLEAVE` clause | Add `type = IN_PARENT` to the `interleave` block (`references/hcl.md`) |
    | A plan creates `PRIMARY KEY ()` | An HCL primary key with `on` blocks: keep descending keys in a SQL schema (`references/hcl.md`) |
    | `unknown block type data in spanner schema` | Seed rows with `INSERT` statements in a migration file (`references/migrations.md`) |
    | `Table not found: INFORMATION_SCHEMA.TABLE_PRIVILEGES` | Roles and grants need a dev database on a real Spanner instance (`references/security.md`) |
    | `modify index "X" must have at least one column to add or drop` | A vector index: exclude it once it exists (`references/objects.md`, Indexes) |
    | `cannot add and drop a column at the same time` | Change one `STORING` column per migration (`references/objects.md`, Indexes) |
    | ``View `V` is missing the SQL SECURITY clause`` | Add `SQL SECURITY INVOKER`, or `DEFINER` (`references/objects.md`, Views) |
    | `Expecting 'INVOKER' but found 'DEFINER'` | Pin emulator 1.5.56 or later (`references/dev-database.md`) |
    | `connected database is not clean: found schema "default". baseline version or allow-dirty is required` | Create a baseline migration and pass `--baseline` (`references/migrations.md`, Existing Databases) |
    | `BadUsage` from a large `UPDATE` or `DELETE` | More than 80,000 mutations in one statement: batch it with `atlas script loop`, or use Partitioned DML (`references/migrations.md`) |
    | `unsupported type` on the PostgreSQL dialect | A `spanner.commit_timestamp` column (`references/objects.md`, PostgreSQL Dialect) |
    | `is not supported in Spanner PostgreSQL dialect` | Atlas cannot plan a PostgreSQL-dialect TTL: exclude the table (`references/objects.md`) |
    | `Cannot reference PG.NUMERIC ... in the creation of index` | PostgreSQL-dialect `numeric`, `jsonb`, and `float4` columns cannot be indexed (`references/objects.md`) |
    | A convention must hold on every table, such as hotspot-free keys | Write a custom lint rule (`references/custom-rules.md`) |
    
    ## Documentation
    
    - Spanner HCL reference: https://atlasgo.io/hcl/spanner
    - Spanner guides: https://atlasgo.io/guides/spanner/automatic-migrations,
      https://atlasgo.io/guides/spanner/proto-columns
    - Dev database: https://atlasgo.io/concepts/dev-database
    - Lint checks: https://atlasgo.io/lint/analyzers
    - Spanner schema design: https://docs.cloud.google.com/spanner/docs/schema-design
    - Spanner schema updates: https://docs.cloud.google.com/spanner/docs/schema-updates,
      https://docs.cloud.google.com/spanner/docs/schema-updates-best-practices
    - Spanner DDL: https://docs.cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language
    - Guides for each database: https://atlasgo.io/databases
    
  • skills/atlas-spanner/references/custom-rules.md7.5 KB157d214b0b12upstream ↗
    # Custom Lint Rules on Spanner
    
    Lint runs Atlas's built-in analyzers, and Spanner has none of its own (`references/migrations.md`). When
    no analyzer covers a check, or the user states a convention, write a custom rule in Atlas's HCL rule
    language. `atlas schema lint` and `atlas migrate lint` enforce it on every change
    (https://atlasgo.io/lint/rules). Lint needs `atlas login`. If `atlas whoami` shows no login, ask the
    user to run `atlas login`; a user without an account can start a free trial with it.
    
    ## The Rule Language
    
    Rules live in `.rule.hcl` files. The language reference is https://atlasgo.io/hcl/rule.
    
    - `predicate "<kind>" "<name>"` is a reusable condition on one kind of object, referenced as
      `predicate.<kind>.<name>`. Each block inside it names an attribute and compares it with `eq`, `ne`,
      `lt`, `le`, `gt`, `ge`, `eq_fold`, `contains`, `contains_fold`, `in`, or `match` (a regular
      expression).
    - `not`, `or`, and `and` combine conditions. `all`, `any`, `exists`, and `count` quantify over child
      objects, such as the columns of a table.
    - `condition` takes an HCL expression over `self`, the current object:
      `primary_key { condition = self != null }`.
    - `variable` blocks parameterize a predicate. The caller passes values with `vars = { ... }`, on an
      `assert` or on a nested block, where `self` is the caller's object.
    - `rule "schema" "<name>"` checks the whole desired schema. `rule "migrate" "<name>"` checks only what
      the analyzed migrations change, wrapped in `add`, `drop`, `modify`, or `rename` blocks. Both need a
      `description`, which appears in the report.
    - Inside a rule, nested blocks walk the objects, such as `table { column { ... } }`. `match` filters
      them, and `assert` applies a predicate and reports its `message` when the predicate is false.
      `${self.name}` and `${self.table.name}` interpolate into messages.
    
    ## What a Rule Can Read on Spanner
    
    These were checked against GoogleSQL and PostgreSQL-dialect schemas:
    
    | Object | Readable | Not readable |
    |--------|----------|--------------|
    | `table` | `name`, `schema`, `primary_key` (with `parts`), child `column`, `index`, and `foreign_key` blocks | `columns` and `indexes` as expressions; interleaving; row deletion policy |
    | `column` | `name`, `type`, `null`, `default`, `self.table.primary_key` | The `primary_key` attribute: `primary_key { eq = true }` never matches; options such as `allow_commit_timestamp` |
    | `index` | `name`, `unique`, `parts` with `column`, `desc`, and `expr` | The types of its columns; `null_filtered`, `STORING` columns, interleaving |
    
    - A column's `type` is the type as Spanner reports it: `INT64`, `STRING(36)`, `TIMESTAMP`, or
      `ARRAY<STRING(64)>` in GoogleSQL, and `bigint`, `character varying(36)`, or
      `timestamp with time zone` in the PostgreSQL dialect.
    - A column's `default` is the expression text, such as
      `GET_NEXT_SEQUENCE_VALUE(SEQUENCE OrderSeq)`, or `nextval('order_seq'::text)` in the PostgreSQL
      dialect.
    - A rule that reads an attribute the object lacks reports
      `Unsupported attribute; This object does not have an attribute named "..."`. When one rule in a file
      fails this way, other rules in the same file can stop reporting, so check each new rule alone first.
    
    ## Examples
    
    Each rule below was checked against a Spanner schema; adapt the closest one before writing a rule from
    scratch. Both enforce Google's guidance to keep new rows from landing on one split: no keys whose first
    part grows with every insert, such as a timestamp or an id the application increments
    (https://docs.cloud.google.com/spanner/docs/schema-design).
    
    A single-column `INT64` primary key that takes its values from a bit-reversed sequence. Interleaved
    tables have two or more key columns, so the rule skips them:
    
    ```hcl
    predicate "table" "single_column_key" {
      primary_key {
        condition = self != null && length(self.parts) == 1
      }
    }
    
    # The column is not the named key column, is not INT64, or gets its value from a sequence.
    predicate "column" "not_a_plain_int64_key" {
      variable "key" {
        type = string
      }
      or {
        name {
          ne = var.key
        }
        type {
          ne = "INT64"
        }
        default {
          match = "GET_NEXT_SEQUENCE_VALUE"
        }
      }
    }
    
    predicate "table" "key_from_sequence" {
      variable "key" {
        type = string
      }
      all {
        column {
          predicate = predicate.column.not_a_plain_int64_key
          vars = {
            key = var.key
          }
        }
      }
    }
    
    rule "schema" "int64-key-from-sequence" {
      description = "A single-column INT64 primary key must take its values from a bit-reversed sequence"
      table {
        match {
          predicate = predicate.table.single_column_key
        }
        assert {
          predicate = predicate.table.key_from_sequence
          vars = {
            key = self.primary_key.parts[0].column
          }
          message = "table ${self.name}: the INT64 primary key has no GET_NEXT_SEQUENCE_VALUE default, so increasing ids written by the application land on one split"
        }
      }
    }
    ```
    
    A primary key that starts with a `TIMESTAMP` column:
    
    ```hcl
    predicate "column" "is_timestamp" {
      type {
        eq = "TIMESTAMP"
      }
    }
    
    predicate "column" "not_named" {
      variable "name" {
        type = string
      }
      name {
        ne = var.name
      }
    }
    
    rule "schema" "no-leading-timestamp-key" {
      description = "A primary key must not start with a TIMESTAMP column"
      table {
        column {
          match {
            predicate = predicate.column.is_timestamp
          }
          assert {
            predicate = predicate.column.not_named
            vars = {
              name = self.table.primary_key.parts[0].column
            }
            message = "the primary key of ${self.table.name} starts with the TIMESTAMP column ${self.name}, so new rows land on one split"
          }
        }
      }
    }
    ```
    
    For the PostgreSQL dialect, change `"INT64"` to `"bigint"`, `"TIMESTAMP"` to
    `"timestamp with time zone"`, and `"GET_NEXT_SEQUENCE_VALUE"` to `"nextval"`.
    
    An index that starts with a timestamp hotspots the same way, but an index cannot read the types of its
    columns. Match the first column's name against the team's naming convention for timestamps instead:
    
    ```hcl
    predicate "table" "no_index_led_by_a_time_column" {
      all {
        index {
          condition = !can(regex("(At|_at|Time)$", self.parts[0].column))
        }
      }
    }
    
    rule "schema" "no-leading-timestamp-index" {
      description = "An index must not start with a timestamp column, by the naming convention"
      table {
        assert {
          predicate = predicate.table.no_index_led_by_a_time_column
          message   = "table ${self.name} has an index that starts with a timestamp column"
        }
      }
    }
    ```
    
    The docs have more, such as naming conventions and foreign keys that reference primary keys
    (https://atlasgo.io/lint/rules#examples).
    
    ## Wire and Run
    
    Add the rule files to `atlas.hcl`, globally or inside an env (https://atlasgo.io/lint/rules):
    
    ```hcl
    env "dev" {
      src = "file://schema.sql"
      dev = "docker://spanner/1.5.58"
      lint {
        rule "hcl" "spanner" {
          src = ["spanner.rule.hcl"]
        }
      }
    }
    ```
    
    - `atlas schema lint --env <name> --url env://src` reports every violation in the schema.
      `atlas migrate lint` reports only the violations that the new migrations introduce.
    - Check a new rule before relying on it: run `atlas schema lint` on a schema that breaks it, and confirm
      it reports those objects and nothing else.
    - Regular expressions in rules and in `statement` blocks use RE2 syntax, which has no lookahead. Express
      "but not" with an `allow` rule before a `deny` rule, or with `or` and `not` in a predicate.
    - Statement rules, which match the SQL text of migration files, catch what object rules cannot, such
      as `DROP CHANGE STREAM` (`references/migrations.md`).
    
  • skills/atlas-spanner/references/dev-database.md8.3 KBc4c3af85ef40upstream ↗
    # Spanner Dev Database and Connections
    
    The dev database is a temporary database Atlas uses to load the desired state, replay migrations, and
    compute plans (https://atlasgo.io/concepts/dev-database). For Spanner it is usually the Spanner emulator
    in Docker, which differs from production in ways this file lists.
    
    ## Scope
    
    A Spanner URL names a database, and Atlas always covers all of it: the default schema and every named
    schema (`CREATE SCHEMA sales`). There is no schema-scoped URL.
    
    - Objects in the default schema are written unqualified (`` `Users` ``), and objects in a named schema
      qualified (`` `sales`.`Orders` ``).
    - A named schema that the desired state does not declare is planned for a drop, after its objects.
      Limit a run with `--schema default`, `schemas = ["default"]` in the env, or `exclude`.
    - `migrate apply` keeps its revisions table in a named schema, `atlas_schema_revisions`, which a
      declarative plan on the same database drops unless excluded (`references/migrations.md`).
    - The dev URL covers a whole database too, so dev and target scopes always match.
    
    ## Docker Dev URLs
    
    ```bash
    # GoogleSQL databases.
    --dev-url "docker://spanner/1.5.58"
    
    # PostgreSQL-dialect databases.
    --dev-url "docker://spannerpg/1.5.58"
    ```
    
    - Both run `gcr.io/cloud-spanner-emulator/emulator:<tag>`, and `spannerpg` creates a
      PostgreSQL-dialect database in it. Match the target's dialect: Atlas reads the target's dialect on its
      own and plans in it.
    - Pin a release. `latest` is whatever image the machine pulled last, and an old one rejects newer DDL:
      `SQL SECURITY DEFINER` views need 1.5.56 or later, and fail on older images with
      `Expecting 'INVOKER' but found 'DEFINER'`.
    - The emulator starts in a few seconds and keeps everything in memory.
    - `docker://` needs a Docker client and a reachable daemon. Without one, run the emulator yourself and
      point `dev` at an empty database in it (Connection URLs, below).
    - There is no `docker "spanner"` block: a config with one fails with
      `missing docker block handler for "spanner"`. The dev database starts empty, without an `init` or a
      `baseline`.
    
    ### Named containers with `atlas tool docker`
    
    `atlas tool docker` starts a named emulator and prints its URL. Use it for a local database to apply
    migrations to (https://atlasgo.io/cli-reference#atlas-tool-docker):
    
    ```bash
    export DATABASE_URL=$(atlas tool docker --url "docker://spanner/1.5.58" --name my-spanner)
    # spanner://host.docker.internal:32929/projects/emulator-project/instances/test-instance/databases/test-database?useplaintext=true
    atlas tool docker kill --name my-spanner
    ```
    
    ## What the Emulator Does Not Do
    
    The emulator accepts most DDL, but it is not production
    (https://docs.cloud.google.com/spanner/docs/emulator):
    
    | Area | On the emulator | Effect on Atlas |
    |------|-----------------|-----------------|
    | Roles and grants | Parsed and ignored; no privilege views; column grants rejected | `mode { roles = true }` or `permissions = true` fails: plan them on a dev database you provide (`references/security.md`) |
    | Placements | Accepted as no-ops | A SQL schema loses them; declare them in HCL (`references/hcl.md`) |
    | Locality groups | Some options not reported | A SQL schema loses `storage`; plans against an emulator target never converge |
    | Vector index options | Not reported | A SQL schema loses them; later plans fail (`references/objects.md`, Indexes) |
    | Mutation limits and quotas | Not enforced | Large data migrations pass tests and fail in production |
    | Some invalid SQL | Accepted | A plan can pass on the emulator and fail on the target |
    | Long-running changes | Finish at once | Index builds and validations take minutes to hours in production (`references/migrations.md`) |
    | Concurrency | One read-write transaction or schema change at a time | Runs on one emulator wait for each other |
    
    ## Your Own Dev Database
    
    For roles and grants, or to plan against exactly what production accepts, point `dev` at an empty
    database on a real Spanner instance, with the target's dialect and edition:
    
    ```bash
    gcloud spanner databases create atlas-dev --instance=<instance>
    gcloud spanner databases create atlas-dev-pg --instance=<instance> --database-dialect=POSTGRESQL
    ```
    
    ```hcl
    env "prod" {
      url = "spanner://projects/<project>/instances/<instance>/databases/orders"
      dev = "spanner://projects/<project>/instances/<instance>/databases/atlas-dev"
    }
    ```
    
    - Atlas loads the desired state into it and drops everything afterwards, leaving it empty. On a real
      instance every one of those statements is a schema change that takes seconds, and Spanner throttles a
      database that receives many of them
      (https://docs.cloud.google.com/spanner/docs/schema-updates-best-practices). Use it only for the envs
      that need it, and keep `docker://` for the rest.
    - Give each env and CI job its own dev database: two runs that share one at the same time see each
      other's objects.
    - Never point `dev` at a real environment's database. Atlas refuses a database that is not empty:
      `connected database is not clean: found table "Users" in default schema "default"`.
    
    ## Connection URLs
    
    - Production: `spanner://projects/<project>/instances/<instance>/databases/<database>`. The URL carries
      no credentials: Atlas uses Application Default Credentials, from
      `gcloud auth application-default login` on a workstation, or the service account of the CI runner
      (https://docs.cloud.google.com/spanner/docs/authentication). Without them, Atlas fails with
      `credentials: could not find default credentials`.
    - The principal needs to read and update the schema and to write the revisions table:
      `roles/spanner.databaseUser` on the database covers it (https://docs.cloud.google.com/spanner/docs/iam).
    - An emulator you run: `spanner://localhost:9010/projects/<project>/instances/<instance>/databases/<database>?useplaintext=true`,
      or the production URL with `SPANNER_EMULATOR_HOST=localhost:9010` set. The emulator starts without
      instances or databases; create them through its REST port:
    
      ```bash
      docker run -d --name spanner -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator:1.5.58
      curl -X POST localhost:9020/v1/projects/my-project/instances -H 'Content-Type: application/json' \
        -d '{"instanceId":"dev","instance":{"config":"emulator-config","displayName":"dev","nodeCount":1}}'
      curl -X POST localhost:9020/v1/projects/my-project/instances/dev/databases -H 'Content-Type: application/json' \
        -d '{"createStatement":"CREATE DATABASE `app`"}'
      # PostgreSQL dialect:
      curl -X POST localhost:9020/v1/projects/my-project/instances/dev/databases -H 'Content-Type: application/json' \
        -d '{"createStatement":"CREATE DATABASE \"app-pg\"","databaseDialect":"POSTGRESQL"}'
      ```
    
      Instance IDs start with a lowercase letter and hold 2 to 64 lowercase letters, digits, and hyphens.
    
    ## Login and the Extended Build
    
    The Spanner driver ships in the extended build of Atlas, and needs a login:
    
    - `Error: The spanner driver is available only as custom build`: install the extended build with
      `curl -sSf https://atlasgo.sh | ATLAS_FLAVOR="spanner" sh`, or use the `arigaio/atlas:latest-extended`
      image.
    - `Abort: The spanner driver is available only to Atlas Pro users`: ask the user to run `atlas login`; a
      user without an account can start a free trial with it.
    
    ## Errors
    
    | Error | Cause | Fix |
    |-------|-------|-----|
    | `The spanner driver is available only as custom build` | The installed Atlas has no Spanner driver | Install the extended build |
    | `The spanner driver is available only to Atlas Pro users` | No login | Ask the user to run `atlas login` |
    | `credentials: could not find default credentials` | No Application Default Credentials | `gcloud auth application-default login`, or a service account |
    | `connected database is not clean` | `dev` points at a database that is not empty | Use a Docker dev URL or an empty database |
    | `Instance not found` or `Database not found` | The instance or database does not exist; an emulator starts with neither | Create them, on an emulator through its REST port |
    | `Table not found: INFORMATION_SCHEMA.TABLE_PRIVILEGES` | Roles or permissions planned on the emulator | Use a dev database you provide |
    | `Expecting 'INVOKER' but found 'DEFINER'` | The emulator image is older than 1.5.56 | Pin a newer emulator release |
    | `missing docker block handler for "spanner"` | A `docker "spanner"` block | Use a `docker://spanner/<version>` URL |
    
  • skills/atlas-spanner/references/hcl.md11 KBc6a293525cbbupstream ↗
    # Writing Spanner Schemas in HCL
    
    The rules of the HCL schema language that matter on Spanner, and the places where HCL and SQL schemas
    plan differently. The language: https://atlasgo.io/atlas-schema/hcl. Every Spanner block and attribute:
    https://atlasgo.io/hcl/spanner. The Spanner driver needs `atlas login`. If `atlas whoami` shows no login,
    ask the user to run `atlas login`; a user without an account can start a free trial with it.
    
    ## HCL or SQL
    
    Pick one format per project. An env cannot mix them: a `src` list with an `.sp.hcl` file and a `.sql`
    file fails with `expect one schema in env`, and a `composite_schema` fails with
    `driver does not support changing connected schema`.
    
    - Use SQL when a primary key has a descending part, such as `PRIMARY KEY (Kind, CreatedAt DESC)`: HCL
      cannot plan it (Keys and Interleaving, below).
    - Use HCL for vector indexes, locality groups, and placements when the dev database is the emulator. A
      SQL schema loses their options, and placements entirely, because the emulator does not report them.
    
    Both formats lose the same objects otherwise: `references/objects.md`, What Atlas Leaves Out.
    
    ## Files and Schemas
    
    - Name Spanner schema files `*.sp.hcl`, test files `*.test.hcl`, and rule files `*.rule.hcl`. The Atlas
      editor plugins recognize `.sp.hcl` for Spanner
      (https://atlasgo.io/atlas-schema/hcl#file-naming-for-editor-support).
    - The default schema is `schema "default" {}` in GoogleSQL and `schema "public" {}` in the PostgreSQL
      dialect. Each named schema (`CREATE SCHEMA sales`) gets its own block, and its tables set
      `schema = schema.sales`.
    - The URL covers the whole database, so the file must declare every named schema the database has, or
      the plan drops the missing ones (`references/dev-database.md`, Scope).
    
    ## Columns
    
    - A column without `null` is `NOT NULL`, the opposite of SQL. Write `null = true` for a nullable column.
    - Types are written inline: `INT64`, `FLOAT64`, `FLOAT32`, `NUMERIC`, `BOOL`, `DATE`, `TIMESTAMP`, `JSON`,
      `UUID`, `TOKENLIST`, `STRING(36)`, and `BYTES(16)`.
    - `STRING(MAX)` and `BYTES(MAX)` are not HCL types: `type = STRING(MAX)` fails with
      `There is no type named "MAX"`. Write `sql("STRING(MAX)")`. Inspection writes `STRING(2621440)` and
      `BYTES(10485760)`, which plan as `MAX` too.
    - Arrays, vectors, and proto types take `sql()`: `sql("ARRAY<STRING(64)>")`,
      `sql("ARRAY<FLOAT32>(vector_length=>768)")`, `sql("examples.shipping.Order")`. Proto types need their
      bundle on the target first (https://atlasgo.io/guides/spanner/proto-columns).
    - `default` takes a literal (`default = 0`, `default = false`) or an expression in `sql()`:
    
      ```hcl
        column "CustomerId" {
          type    = STRING(36)
          default = sql("GENERATE_UUID()")
        }
        column "CreatedAt" {
          type    = TIMESTAMP
          default = sql("CURRENT_TIMESTAMP()")
        }
      ```
    
    - A generated column takes an `as` block. `type = STORED` stores the values; without `type` the column
      is computed on read; `type = HIDDEN` hides a `TOKENLIST` column from `SELECT *`:
    
      ```hcl
        column "EmailLower" {
          type = STRING(320)
          null = true
          as {
            expr = "LOWER(Email)"
            type = STORED
          }
        }
        column "Body_Tokens" {
          type = TOKENLIST
          null = true
          as {
            expr = "TOKENIZE_FULLTEXT(Body)"
            type = HIDDEN
          }
        }
      ```
    
      Changing the expression of a stored column is planned as a drop and an add of the column.
    - An `options` block sets column options:
    
      ```hcl
        column "UpdatedAt" {
          type = TIMESTAMP
          null = true
          options {
            allow_commit_timestamp = true
          }
        }
      ```
    
      It also takes `locality_group = locality.cold` (Locality Groups and Placements, below).
    - There is no `identity` block and no `renamed_from`: identity columns and renames are covered in
      `references/objects.md`.
    
    ## Keys and Interleaving
    
    - `primary_key` takes `columns`:
    
      ```hcl
        primary_key {
          columns = [column.SingerId, column.AlbumId]
        }
      ```
    
      For a descending key part, inspection writes `on` blocks, and those do not plan. A new table gets
      `PRIMARY KEY ()`, a table that holds at most one row, and an existing table fails with
      `the keys of a table cannot change after table creation`. Keep a schema with descending key parts in
      SQL (HCL or SQL, above).
    - An interleaved table takes an `interleave` block. Always set `type = IN_PARENT`:
    
      ```hcl
      table "Albums" {
        schema = schema.default
        # ...
        primary_key {
          columns = [column.SingerId, column.AlbumId]
        }
        interleave {
          parent    = table.Singers
          type      = IN_PARENT
          on_delete = CASCADE
        }
      }
      ```
    
      - Without `type`, Atlas plans ``INTERLEAVE `Singers` ``, which Spanner rejects with
        `Syntax error ... Expecting 'IN'`.
      - `type = IN` plans `INTERLEAVE IN`, and a database that holds such a table can no longer be
        inspected (`references/objects.md`, Interleaving).
      - `on_delete` takes `CASCADE` or `NO_ACTION`, the default.
      - Inspection adds `depends_on = [table.Singers]`.
    
    ## Indexes, Foreign Keys, and Checks
    
    - An `index` takes `columns`, or `on` blocks with `column` and `desc`, plus `unique`, `null_filtered`
      (`NULL_FILTERED`), and `include` (the `STORING` columns):
    
      ```hcl
        index "AlbumsByTitle" {
          columns = [column.Title]
          include = [column.Price]
        }
        index "SingersByEmail" {
          unique        = true
          null_filtered = true
          columns       = [column.Email]
        }
        index "EventsByTime" {
          on {
            column = column.Kind
          }
          on {
            column = column.CreatedAt
            desc   = true
          }
        }
      ```
    
      Adding a column to `include` plans `ALTER INDEX ... ADD STORED COLUMN`.
    - `interleave_in` is accepted and ignored: the index is planned as a global index
      (`references/objects.md`, Indexes).
    - A search index takes `type = SEARCH` over `TOKENLIST` columns. A vector index takes `type = VECTOR`
      and its options, which only HCL keeps:
    
      ```hcl
        index "DocsEmbeddingIdx" {
          columns       = [column.Embedding]
          type          = VECTOR
          distance_type = COSINE
          tree_depth    = 2
          num_leaves    = 1000
          where         = "Embedding IS NOT NULL"
        }
      ```
    
      Inspection does not read the options back from the emulator, so once the index exists there, every
      later plan fails with `modify index "DocsEmbeddingIdx" must have at least one column to add or drop`.
      Exclude the index once it exists (`references/objects.md`, Indexes).
    - `foreign_key` takes `columns`, `ref_columns`, and `on_delete` (`CASCADE` or `NO_ACTION`). There is no
      attribute for `NOT ENFORCED`:
    
      ```hcl
        foreign_key "FK_PaymentsCustomer" {
          columns     = [column.CustomerId]
          ref_columns = [table.Customers.column.CustomerId]
          on_delete   = CASCADE
        }
      ```
    
    - `check` takes `expr`. A changed expression is planned as a drop and an add of the constraint, which
      checks every row again.
    
    ## Tables
    
    - `row_deletion_policy` sets a TTL, in GoogleSQL only: in the PostgreSQL dialect a TTL breaks planning
      (`references/objects.md`, PostgreSQL Dialect).
    
      ```hcl
      table "Events" {
        schema              = schema.default
        row_deletion_policy = sql("OLDER_THAN(CreatedAt, INTERVAL 30 DAY)")
        # ...
      }
      ```
    
      A changed interval plans `ALTER TABLE ... REPLACE ROW DELETION POLICY`.
    - `locality_group = locality.hot` puts the table in a locality group.
    
    ## Sequences
    
    ```hcl
    sequence "OrderSeq" {
      kind               = bit_reversed_positive
      skip_range_min     = 1
      skip_range_max     = 1000
      start_with_counter = 5000
    }
    
    table "Orders" {
      schema = schema.default
      column "OrderId" {
        type    = INT64
        default = sql("GET_NEXT_SEQUENCE_VALUE(SEQUENCE OrderSeq)")
      }
      # ...
    }
    ```
    
    - A sequence has no `schema` attribute and lives in the default schema. A sequence in a named schema,
      written in SQL as `CREATE SEQUENCE sales.OrderSeq`, breaks planning with
      `Drop sequence "OrderSeq": ... Sequence not found`.
    - Option changes plan `ALTER SEQUENCE ... SET OPTIONS`.
    
    ## Views
    
    ```hcl
    view "EmployeeNames" {
      schema     = schema.default
      as         = "SELECT e.Id, e.Name FROM Employees AS e"
      security   = INVOKER
      depends_on = [table.Employees]
    }
    ```
    
    - `security` is required by Spanner: `INVOKER`, or `DEFINER` for a view that roles read without access
      to its tables (`references/security.md`). A change to `as` plans `CREATE OR REPLACE VIEW`.
    
    ## Change Streams
    
    ```hcl
    stream "OrdersStream" {
      tables = [table.Orders]
      options = {
        retention_period   = "7d"
        value_capture_type = "NEW_ROW"
      }
    }
    
    stream "EverythingStream" {
      for_all = true
    }
    
    stream "DocsTitleStream" {
      for {
        table   = table.Docs
        columns = [table.Docs.column.Title, table.Docs.column.Price]
      }
    }
    ```
    
    A change to `options` is planned as `DROP CHANGE STREAM` and `CREATE CHANGE STREAM`, which deletes the
    stream's change records: write `ALTER CHANGE STREAM` by hand (`references/migrations.md`).
    
    ## Locality Groups and Placements
    
    ```hcl
    locality "cold" {
      storage = "hdd"
    }
    
    locality "recent" {
      storage                   = "ssd"
      ssd_to_hdd_spill_timespan = "30d"
    }
    
    placement "europe" {
      instance_partition = "euro-partition"
      default_leader     = "europe-west1"
    }
    
    table "Orders" {
      schema         = schema.default
      locality_group = locality.cold
      column "Location" {
        type          = sql("STRING(MAX)")
        placement_key = true
      }
      # ...
    }
    ```
    
    Locality groups need the Enterprise edition, and placements the Enterprise Plus edition. The emulator
    does not report them back, so a SQL schema loses them on an emulator dev database, and plans against an
    emulator target never converge; from HCL, Atlas plans them on the emulator too
    (`references/dev-database.md`, What the Emulator Does Not Do).
    
    ## Property Graphs
    
    Inspection writes graphs with explicit keys:
    
    ```hcl
    property_graph "Social" {
      schema = schema.default
      node_table {
        table = table.Person
        key {
          columns = [table.Person.column.Id]
        }
      }
      edge_table {
        table = table.Knows
        key {
          columns = [table.Knows.column.Id]
        }
        source_key {
          columns     = [table.Knows.column.FromId]
          ref_columns = [table.Person.column.Id]
        }
        destination_key {
          columns     = [table.Knows.column.ToId]
          ref_columns = [table.Person.column.Id]
        }
      }
    }
    ```
    
    A change plans `CREATE OR REPLACE PROPERTY GRAPH`, before it drops a table the graph no longer names.
    Spanner Graph is GoogleSQL only.
    
    ## Roles and Permissions
    
    Covered in `references/security.md`.
    
    ## Seed Data
    
    The `data` block is not supported on Spanner: a schema file with one fails with
    `unknown block type data in spanner schema`. Insert seed rows with `INSERT` statements in a migration
    file (`references/migrations.md`).
    
    ## Input Variables
    
    Input variables work as in any Atlas HCL schema (https://atlasgo.io/atlas-schema/input-variables). A
    variable without a default that gets no value fails the run.
    
  • skills/atlas-spanner/references/migrations.md14 KB046deacce3deupstream ↗
    # Spanner Migrations: Transactions, Long-Running Changes, and Migration Files
    
    How Atlas runs migrations on a database without transactional DDL, how to keep Spanner's long-running
    schema changes under control, and what to write by hand. Tests are in `references/testing.md`. The
    Spanner driver, lint, custom rules, and tests need `atlas login`. If `atlas whoami` shows no login, ask
    the user to run `atlas login`; a user without an account can start a free trial with it.
    
    ## Every File Starts with `-- atlas:txmode none`
    
    Spanner cannot run DDL inside a transaction, and `migrate apply` wraps each file in one unless the file
    opts out. `atlas migrate diff` writes the directive at the top of every file it generates:
    
    ```sql
    -- atlas:txmode none
    
    -- Create "Singers" table
    CREATE TABLE `Singers` (
      `SingerId` STRING(36) NOT NULL,
      `Name` STRING(MAX) NOT NULL
    ) PRIMARY KEY (`SingerId`);
    ```
    
    - `atlas migrate new` creates an empty file without it. Add it to every hand-written file, or the file
      fails on the target with
      `spanner: code = "FailedPrecondition", desc = "cannot execute DDL as part of a transaction"`.
    - `atlas migrate lint` and `atlas migrate validate` accept a file without the directive.
      `atlas migrate test` fails on it, and so does applying it to a local emulator
      (`references/dev-database.md`).
    - `atlas migrate apply --tx-mode none` turns transactions off for a whole run.
    - `atlas schema clean` always runs in a transaction and fails on Spanner with the same error. Reset a
      database by applying an empty schema with `atlas schema apply`, or drop and recreate it with `gcloud`.
    
    ## How Atlas Runs Statements
    
    Atlas sends one statement at a time, and Spanner runs each DDL statement as its own schema change,
    a long-running operation on the server. Data statements in the file commit one by one. The Spanner
    guide's run takes 13 to 17 seconds per statement against a real instance
    (https://atlasgo.io/guides/spanner/automatic-migrations).
    
    - A file or a declarative plan that fails halfway stays half applied. `atlas migrate status` shows a
      failed file as partially applied:
    
      ```text
      Migration Status: PENDING
        -- Current Version: 20261001000003 (1 statements applied)
        -- Next Version:    20261001000003 (2 statements left)
        -- Executed Files:  3 (last one partially)
        -- Pending Files:   1
    
      Last migration attempt had errors:
        -- SQL:   ALTER TABLE `Accounts` ALTER COLUMN `Nick` STRING(64) NOT NULL
        -- ERROR: rpc error: code = FailedPrecondition desc = Cannot specify a null value for column: Nick in table: Accounts referenced by key: {Int64(1)}
      ```
    
    - The next `atlas migrate apply` continues from the statement that failed. Fix that statement and the
      ones after it, leave the applied ones unchanged, and run `atlas migrate hash`.
    - `atlas migrate down` reverts applied files on Spanner, statement by statement. It computes the revert
      on the dev database and checks that a column it drops holds no data
      (https://atlasgo.io/versioned/down).
    - `atlas schema apply` stops at the failed statement, and the next plan lists what is left.
    - A deployment job that dies during a long statement, such as an index build, does not stop the schema
      change on Spanner. Check it with
      `gcloud spanner operations list --instance=<instance> --database=<database> --type=DATABASE_UPDATE_DDL`
      before running the file again; the rerun fails with a duplicate name if the statement finished. The
      `if_not_exists` diff policy writes `ADD COLUMN IF NOT EXISTS` and `CREATE INDEX IF NOT EXISTS`, which a
      rerun skips (https://atlasgo.io/versioned/diff#diff-policy):
    
      ```hcl
      env "prod" {
        diff {
          add_column {
            if_not_exists = true
          }
          add_index {
            if_not_exists = true
          }
        }
      }
      ```
    
    ## Long-Running Changes
    
    Some statements make Spanner read every row of a table, and run from minutes to hours on a large one.
    Reads and writes continue meanwhile, but conflicting schema changes wait
    (https://docs.cloud.google.com/spanner/docs/schema-updates#updates-that-require-validation):
    
    | Statement | What Spanner does |
    |-----------|-------------------|
    | `CREATE INDEX` on a populated table | Backfills the index |
    | `ADD COLUMN` with a stored generated expression | Backfills the column, which cannot be read until done |
    | `ALTER COLUMN ... NOT NULL`, a shorter `STRING(n)` or `BYTES(n)`, `BYTES` to `STRING` | Validates every row; rejects new writes that break the change at once |
    | `ADD CONSTRAINT ... CHECK` or `FOREIGN KEY` | Validates every row; enforces the constraint on new writes at once |
    | `allow_commit_timestamp = true` on an existing column | Validates that every value is in the past |
    
    Google's guidance for these
    (https://docs.cloud.google.com/spanner/docs/schema-updates-best-practices):
    
    - Put no more than 10 of them in one batch, and add no more than 3 indexes that need a backfill per day.
    - Spanner throttles a database that receives many schema changes in a short time.
    - Create a table's indexes together with the table, while it is empty.
    
    With Atlas, where every statement is its own schema change:
    
    - Keep these statements in small files of their own, apart from other DDL and from data changes.
    - Spread index builds over deployments: `atlas migrate apply <n>` applies the next `n` files.
    - An initial schema of hundreds of statements takes as many schema changes. To load it as one batch,
      create the database with `gcloud spanner databases ddl update <database> --instance=<instance>
      --ddl-file=schema.sql`, then record the baseline migration as applied (Existing Databases, below).
    - Watch and cancel a running change with `gcloud spanner operations list` and
      `gcloud spanner operations cancel`. If `migrate apply` is still waiting on the cancelled statement, the
      file fails there: fix it and apply again.
    
    ## What Lint Catches on Spanner
    
    Spanner has no analyzers of its own, like the `MY` and `PG` checks of MySQL and PostgreSQL. The generic
    ones run (https://atlasgo.io/lint/analyzers):
    
    | Code | Reports |
    |------|---------|
    | `DS101` to `DS103` | Dropping a schema, a table, or a column that holds data |
    | `BC101` to `BC104` | Renaming or dropping a table or column that clients use |
    | `MF101` | A unique index on existing data, which fails on duplicates |
    | `MF104` | A nullable column made `NOT NULL`, which fails on `NULL` rows |
    
    Lint does not report a shorter `STRING(n)`, a foreign key or check added to a populated table, an index
    backfill, or a recreated change stream. It does replay each file on the dev database, so a statement
    the emulator rejects, such as a `DROP COLUMN` before the index that uses it, fails lint instead of the
    deployment. Cover the rest with custom rules (`references/custom-rules.md`) and a `statement` rule
    (https://atlasgo.io/lint/analyzers#statement-rules):
    
    ```hcl
    lint {
      statement {
        deny "drop-change-stream" {
          match   = "(?is)^\\s*DROP\\s+CHANGE\\s+STREAM\\b"
          message = "DROP CHANGE STREAM deletes the stream's change records: change its options with ALTER CHANGE STREAM ... SET OPTIONS"
        }
      }
    }
    ```
    
    It reports each `DROP CHANGE STREAM` as a warning; set `error = true` in the `statement` block to fail
    the run. A statement opts out of named checks with a directive on the line before it
    (https://atlasgo.io/versioned/lint#nolint-directive):
    
    ```sql
    -- atlas:nolint DS102 BC103
    DROP TABLE `LegacyEvents`;
    ```
    
    ## Dependent Objects
    
    Spanner refuses to drop a column that an index, a `STORING` list, a view, a foreign key, a check, a
    generated column, or a row deletion policy uses
    (https://docs.cloud.google.com/spanner/docs/schema-updates#supported-updates). When a change removes a
    column together with the object that uses it, Atlas plans the `DROP COLUMN` first:
    
    ```sql
    -- Drop column "Nick" from table "Users"
    ALTER TABLE `Users` DROP COLUMN `Nick`;
    -- Drop index "UsersByNick" from table "Users"
    DROP INDEX `UsersByNick`;
    ```
    
    ```
    Cannot drop column Nick from table Users because it is used by index UsersByNick.
    Cannot drop column `Nick` on which there are dependent views: SingerNames.
    ```
    
    `atlas migrate diff` writes the file without an error. `atlas migrate lint`, `atlas migrate validate`,
    and `atlas schema apply` fail on it, because they replay it on the dev database. Move the `DROP INDEX`,
    `ALTER INDEX ... DROP STORED COLUMN`, or `CREATE OR REPLACE VIEW` above the `DROP COLUMN` and run
    `atlas migrate hash`, or remove the dependent object in one migration and the column in the next. In the
    declarative workflow, apply the two steps one after the other.
    
    ## Changes to Write by Hand
    
    - Change streams. Atlas recreates a stream for any change, which deletes its change records. Write the
      change instead, and keep the schema in step:
    
      ```sql
      -- atlas:txmode none
    
      ALTER CHANGE STREAM SingersBio SET FOR Singers(Name);
      ALTER CHANGE STREAM EventsStream SET OPTIONS (retention_period = '3d');
      ```
    
    - Interleaved indexes and `NOT ENFORCED` foreign keys, which Atlas plans without those clauses
      (`references/objects.md`, What Atlas Leaves Out).
    - Database options, which Atlas leaves out of plans:
    
      ```sql
      -- atlas:txmode none
    
      ALTER DATABASE `orders-db` SET OPTIONS (version_retention_period = '3d');
      ```
    
      `default_sequence_kind` cannot be changed once set, and `default_time_zone` only on an empty database.
    - A type change Spanner cannot make in place: add the new column, backfill it, switch the application,
      then drop the old column in a later file.
    - A primary key change, or adding or removing interleaving: create the new table, copy the rows, switch
      the application, then drop the old table in a later file.
    
    ## Renames
    
    Atlas plans a renamed table as a drop and a create, which loses the rows (`DS102`), and Spanner HCL has
    no `renamed_from`. Spanner renames tables, not columns.
    
    1. Write the rename in a migration file. A synonym keeps the old name working for queries until the
       application moves to the new one; Atlas ignores synonyms. Lint reads the rename as a dropped table and
       fails on it, so after checking it, silence `DS102` and `BC103`:
    
       ```sql
       -- atlas:txmode none
    
       -- atlas:nolint DS102 BC103
       ALTER TABLE Legacy RENAME TO Accounts, ADD SYNONYM Legacy;
       ```
    
    2. Rename the table in the schema. The next `migrate diff` reports no changes.
    3. Once no query uses the old name, drop the synonym by hand: `ALTER TABLE Accounts DROP SYNONYM Legacy`.
    
    In the declarative workflow, apply the rename on its own, before other changes: change only the table
    name in the schema, run `atlas schema apply --env <name> --edit`, and replace the planned `CREATE TABLE`
    and `DROP TABLE` with the `ALTER TABLE ... RENAME TO` statement (the `atlas` skill,
    `references/declarative.md`, Editing a plan). Check the edited plan before approving it: a plan that
    still drops the old table loses its rows.
    
    A column cannot be renamed: add a new column, backfill it, and drop the old one in a later file.
    
    ## Data Changes
    
    - Each `INSERT`, `UPDATE`, or `DELETE` in a migration file commits on its own. One DML statement makes
      up to 80,000 mutations, counting every column it writes and every index entry it changes, and a
      larger one fails with a `BadUsage` error (https://docs.cloud.google.com/spanner/docs/dml-tasks). An
      `UPDATE` over a large table exceeds it in production, while the emulator does not enforce the limit,
      so a migration test passes.
    - Backfill large tables in batches with `atlas script loop`, which commits each batch on its own
      (https://atlasgo.io/scripts/loop). Spanner takes `@p1` placeholders, and `JSON_VALUE_ARRAY` expands a
      JSON list:
    
      ```hcl
      script "loop" "backfill_email_norm" {
        iterator "keyset" {
          cursor {
            id = int
          }
          batch {
            id = int
          }
          init {
            sql = "SELECT Id AS id FROM Users WHERE EmailNorm IS NULL ORDER BY Id LIMIT ${ramp.size}"
          }
          next {
            sql  = "SELECT Id AS id FROM Users WHERE EmailNorm IS NULL AND Id > @p1 ORDER BY Id LIMIT ${ramp.size}"
            args = [cursor.id]
          }
        }
        do {
          exec {
            sql  = "UPDATE Users SET EmailNorm = LOWER(TRIM(Email)) WHERE Id IN UNNEST(ARRAY(SELECT CAST(v AS INT64) FROM UNNEST(JSON_VALUE_ARRAY(@p1)) AS v))"
            args = [jsonencode(iterator.keyset.batch[*].id)]
          }
        }
        assert "none_left" {
          sql = "SELECT COUNT(*) = 0 FROM Users WHERE EmailNorm IS NULL"
        }
        policy {
          ramp {
            stage { size = 1000 }
          }
        }
      }
      ```
    
      Alias the cursor column to the name the `cursor` block uses (`Id AS id`). Run it with
      `atlas script loop --env <name> --file file://backfill.hcl --run backfill_email_norm`.
    - Or run a single statement as Partitioned DML, outside Atlas:
      `gcloud spanner databases execute-sql <database> --instance=<instance> --enable-partitioned-dml --sql="UPDATE ..."`.
    - Seed rows go in migration files as `INSERT` statements: Spanner HCL has no `data` block.
    
    ## Revisions Table
    
    - Atlas keeps the revisions table in a named schema, `atlas_schema_revisions`, which it creates on the
      first `migrate apply`. `atlas schema inspect` shows it.
    - A declarative plan on the same database drops it, unless the env excludes it:
      `exclude = ["atlas_schema_revisions"]`.
    
    ## Existing Databases
    
    A database that has objects but no revisions table is refused until it gets a baseline, the first
    migration recorded as applied without running (https://atlasgo.io/versioned/apply#existing-databases):
    
    ```
    Error: sql/migrate: connected database is not clean: found schema "default". baseline version or allow-dirty is required
    ```
    
    ```bash
    atlas migrate diff baseline \
      --dir "file://migrations" \
      --dev-url "docker://spanner/1.5.58" \
      --to "spanner://projects/<project>/instances/<instance>/databases/<database>"
    ```
    
    Then pass its version once with `atlas migrate apply --baseline <version>`, or set `baseline` in the
    env's `migration` block. The baseline holds only what Atlas plans: add identity columns, interleaved
    indexes, `NOT ENFORCED` foreign keys, and database options to it by hand, so new databases get them
    too (`references/objects.md`). Proto bundles cannot go in a migration file: create them with `gcloud`
    before the first `migrate apply` on a new database.
    
    ## Large Changes
    
    To spread a large change over several deployments, split it into several migration files and apply a few
    at a time with `atlas migrate apply <n>`.
    
  • skills/atlas-spanner/references/objects.md19 KB35487565c12bupstream ↗
    # Spanner Objects and Their Nuances
    
    How Atlas models Spanner objects, what Spanner allows to change in place, and the cases where Atlas's plan
    differs from what a hand-written migration would do. The full attribute reference is
    https://atlasgo.io/hcl/spanner. HCL syntax is in `references/hcl.md`, and running the changes is in
    `references/migrations.md`. The Spanner driver needs `atlas login`. If `atlas whoami` shows no login,
    ask the user to run `atlas login`; a user without an account can start a free trial with it.
    
    ## What Atlas Manages
    
    Atlas inspects and plans tables, columns with their defaults, generated expressions, and options,
    primary keys, `INTERLEAVE IN PARENT`, secondary indexes, search and vector indexes, foreign keys, checks,
    row deletion policies, sequences, views, change streams, named schemas, property graphs, locality groups,
    placements, and roles and grants (https://atlasgo.io/hcl/spanner).
    
    ## What Atlas Leaves Out
    
    These were checked with the emulator as dev database. Each is planned without an error, so a plan that
    looks complete can still miss them:
    
    | Object or clause | What happens | What to do |
    |------------------|--------------|------------|
    | Identity columns, `GENERATED BY DEFAULT AS IDENTITY` | Planned as a plain `INT64 NOT NULL`: inserts that omit the key fail | Use a named sequence (Sequences, below) |
    | A table without a primary key | Planned with a visible `rowid INT64 NOT NULL` key and no generator | Declare a primary key |
    | `NOT ENFORCED` foreign keys | Planned as enforced foreign keys, which validate every row | Create them by hand (Foreign Keys, below) |
    | Interleaved indexes, `CREATE INDEX ... , INTERLEAVE IN Parent` | Planned as global indexes | Create them by hand in a migration file |
    | `INTERLEAVE IN` tables, without `PARENT` | Inspection fails: `Scan error on column index 3, name "on_delete_action": converting NULL to string is unsupported` | Use `INTERLEAVE IN PARENT` (Interleaving, below) |
    | Adding or removing interleaving on an existing table | The plan reports no changes | Interleaving is permanent: create a new table and copy the rows |
    | Database options, `ALTER DATABASE ... SET OPTIONS` | Left out of plans | Write them in a migration file (`references/migrations.md`) |
    | Synonyms, `ADD SYNONYM` | Not inspected or planned | Manage them by hand (`references/migrations.md`, Renames) |
    | Proto bundles | Atlas cannot send the descriptor set Spanner needs | Update the bundle with `gcloud` first (https://atlasgo.io/guides/spanner/proto-columns) |
    | A sequence in a named schema | Planning fails: `Drop sequence "OrderSeq": ... Sequence not found` | Keep sequences in the default schema |
    | Vector index options, locality group options, and placements, in a SQL schema | Lost on an emulator dev database | Declare them in HCL (`references/hcl.md`) |
    
    Other changes reach the plan in a form Spanner rejects, or that loses data:
    
    | Change | What Atlas plans | What to do |
    |--------|------------------|------------|
    | Remove a column and the index, `STORING` list, or view that uses it | `DROP COLUMN` first, which fails: `Cannot drop column ... because it is used by index ...`, or `on which there are dependent views` | Drop or replace the dependent object first (`references/migrations.md`, Dependent Objects) |
    | Change the expression of an indexed stored generated column | `DROP COLUMN` and `ADD COLUMN`, which fails on the index | Drop the index, replace the column, then recreate the index |
    | Change a change stream's options or watched columns | `DROP CHANGE STREAM` and `CREATE CHANGE STREAM`, which deletes its change records | Write `ALTER CHANGE STREAM` by hand (Change Streams, below) |
    | Rename a table | A drop and a create, which loses the rows (`DS102`) | Write the rename by hand (`references/migrations.md`, Renames) |
    
    ## Keys and Hotspots
    
    Spanner splits a table by primary key ranges. Keys that grow with every insert, such as a timestamp or an
    id the application increments, send all new rows to the last split, which caps write throughput
    (https://docs.cloud.google.com/spanner/docs/schema-design#primary-key-prevent-hotspots). Pick one of:
    
    - A UUID version 4: `STRING(36) DEFAULT (GENERATE_UUID())`, or the `UUID` type with
      `DEFAULT (NEW_UUID())`. Not version 1, which puts the timestamp in the high bits.
    - A bit-reversed sequence for `INT64` keys (Sequences, below).
    - A hash or shard prefix, a swapped key order, or a descending timestamp key, from the same page.
    
    The same applies to indexes: do not create a non-interleaved index on a frequently written column whose
    value only grows, and do not lead a key or index with a commit timestamp column
    (https://docs.cloud.google.com/spanner/docs/commit-timestamp#keys-indexes). The custom rules in
    `references/custom-rules.md` enforce this.
    
    - Primary keys cannot change after the table exists. A changed key fails planning with
      `spanner: the keys of a table cannot change after table creation`. Create a new table, copy the rows,
      and switch the application over.
    - Keys hold up to 16 columns, including those inherited from parent tables, and 8 KiB
      (https://docs.cloud.google.com/spanner/quotas#schema-limits). `FLOAT32`, `ARRAY`, and `JSON` columns
      cannot be keys or index keys
      (https://docs.cloud.google.com/spanner/docs/reference/standard-sql/data-types#valid_key_column_types).
    - Descending key parts plan only from SQL schemas (`references/hcl.md`, Keys and Interleaving).
    
    ## Interleaving
    
    `INTERLEAVE IN PARENT` stores child rows with their parent row: the parent's primary key must lead the
    child's key, a child row needs its parent row, and `ON DELETE CASCADE` deletes children with the parent.
    Tables nest up to 7 levels
    (https://docs.cloud.google.com/spanner/docs/schema-and-data-model#create-interleaved-tables).
    
    - Interleaving is permanent: Spanner cannot interleave an existing table or remove its interleaving, and
      Atlas then reports no changes. Create a new table and copy the rows.
    - An `ON DELETE` change is planned in place:
      `ALTER TABLE Albums SET INTERLEAVE IN PARENT Singers ON DELETE CASCADE`.
    - Atlas cannot inspect a database that has a table interleaved with `INTERLEAVE IN`, without
      `PARENT`, so every command that reads the database fails. Convert the table once, outside Atlas:
    
      ```bash
      gcloud spanner databases ddl update <database> --instance=<instance> \
        --ddl='ALTER TABLE Albums SET INTERLEAVE IN PARENT Singers'
      ```
    
      The conversion fails when child rows have no parent row. Going from `INTERLEAVE IN` to
      `ON DELETE CASCADE` takes two statements: `SET INTERLEAVE IN PARENT`, then `SET ON DELETE CASCADE`
      (https://docs.cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#alter_table).
    - A key column that interleaved children inherit cannot change, not even its length: planning fails with
      `Requested change to key column Singers.SingerId could not be made`.
    - A table with a row deletion policy needs `ON DELETE CASCADE` on all its interleaved children
      (Row Deletion Policies, below).
    - Google recommends either a foreign key or interleaving between two tables, not both
      (https://docs.cloud.google.com/spanner/docs/foreign-keys/overview).
    
    ## Columns and Types
    
    - Spanner changes a column's type in place only between `STRING` and `BYTES`, to another length, from
      `INT64` to an `ENUM`, and between proto types
      (https://docs.cloud.google.com/spanner/docs/schema-updates#supported-updates). Atlas plans any other
      change as `ALTER COLUMN`, and planning fails with
      ``Cannot change type of column `Age` from `INT64` to `STRING` ``. Add a new column, backfill it, switch
      the application, and drop the old column in a later migration.
    - A shorter `STRING(n)` or `BYTES(n)` checks every row, and fails on a longer value:
      `Reducing the length of column Nick to 5 is not allowed because it has a value of length 8`. Lint
      does not report it.
    - A new `NOT NULL` column on an existing table needs a `DEFAULT`, or a stored generated expression.
      Without one, planning fails with `Cannot add NOT NULL column Users.Status to existing table Users`. An
      `ARRAY` column can be `NOT NULL` only when its table is created.
    - Making a column `NOT NULL` checks every row, and fails on `NULL` rows even when the column has a
      `DEFAULT`: `ALTER COLUMN` does not backfill. Spanner rejects new `NULL` writes as soon as the change
      starts (https://docs.cloud.google.com/spanner/docs/schema-updates#updates-that-require-validation).
      Lint reports it as `MF104`; backfill first (`references/migrations.md`).
    - `ALTER COLUMN` replaces the whole column definition, and drops a `NOT NULL` or `DEFAULT` it does not
      repeat. Atlas repeats them, so check hand-written `ALTER COLUMN` statements for the same.
    - `allow_commit_timestamp = true` lets the column take `PENDING_COMMIT_TIMESTAMP()`. Turning it on for an
      existing column checks that its values are in the past
      (https://docs.cloud.google.com/spanner/docs/commit-timestamp).
    - `STRING(MAX)` holds 2,621,440 characters and `BYTES(MAX)` 10,485,760 bytes. `NUMERIC` has precision 38
      and scale 9. A cell holds up to 10 MiB.
    - Names hold 1 to 128 characters, and two names that differ only in case collide. Spanner reserves
      words such as `AT`, `NEW`, and `ALL`, which fail in a SQL schema with a `Syntax error` unless quoted with
      backticks. Atlas quotes every name it writes.
    
    ## Indexes
    
    - Building an index on a populated table backfills it, which takes minutes to hours. Google advises at
      most 3 new backfilled indexes a day, and creating a table's indexes together with the table
      (https://docs.cloud.google.com/spanner/docs/schema-updates-best-practices#large-updates).
    - A plain `UNIQUE` index treats `NULL`s as equal, so two rows with a `NULL` key collide. A
      `UNIQUE NULL_FILTERED` index skips rows with a `NULL` key part and does not enforce uniqueness for them
      (https://docs.cloud.google.com/spanner/docs/secondary-indexes#unique-indexes). Creating a unique index
      fails on duplicate rows (`MF101`).
    - `STORING` columns change in place: Atlas plans `ALTER INDEX ... ADD STORED COLUMN` or
      `DROP STORED COLUMN`. Replacing one stored column with another fails planning with
      `cannot add and drop a column at the same time`: change one column per migration.
    - An index's key columns cannot change: Atlas drops and recreates the index, which backfills again.
    - Search indexes run over hidden `TOKENLIST` columns, and need the Enterprise edition. Vector indexes need
      a `vector_length` on the column, a `WHERE col IS NOT NULL` for a nullable column, and
      `distance_type` (https://docs.cloud.google.com/spanner/docs/vector-indexes). Declare vector indexes in
      HCL, and exclude them once created: `exclude = ["*.Docs.DocsEmbeddingIdx"]`. Inspection does not read
      their options back from the emulator, so later plans fail with
      `modify index "DocsEmbeddingIdx" must have at least one column to add or drop`.
    
    ## Foreign Keys
    
    - Spanner backs each foreign key with indexes it manages, which inspection does not show. A foreign key
      takes `ON DELETE CASCADE` or `NO ACTION`.
    - Adding a foreign key to a populated table checks every row, and the change fails on rows that break it
      (https://docs.cloud.google.com/spanner/docs/foreign-keys/overview).
    - A changed foreign key is planned as `DROP CONSTRAINT` and `ADD CONSTRAINT` with the same name, which
      leaves the table unchecked until the new one validates. Google advises adding the new constraint
      before dropping the old one: rename it in the schema, and move the `ADD CONSTRAINT` above the
      `DROP CONSTRAINT` in the migration file.
    - Informational foreign keys, `NOT ENFORCED`, are not validated or enforced. Atlas plans them as
      enforced, and inspects them as enforced. Create them in a hand-written migration file; declaring them
      the same way in a SQL schema then plans no change. The same holds for interleaved indexes.
    
    ## Checks, Generated Columns, and Defaults
    
    - A check must be deterministic, and cannot read `allow_commit_timestamp` columns. Adding one checks
      every row and fails on rows that break it. Spanner cannot modify a check, so Atlas drops and re-adds it
      (https://docs.cloud.google.com/spanner/docs/check-constraint/how-to).
    - A generated column uses only immutable functions. Adding a stored one backfills it, and it cannot be
      read until the backfill finishes. Spanner cannot change a stored or indexed generated expression, so
      Atlas drops and re-adds the column, which fails when an index uses it (What Atlas Leaves Out, above).
      A non-stored generated column cannot be `NOT NULL`
      (https://docs.cloud.google.com/spanner/docs/generated-column/how-to).
    - A `DEFAULT` can be non-deterministic, such as `CURRENT_TIMESTAMP()` or `GENERATE_UUID()`, and cannot
      read other columns. A changed default is planned as `ALTER COLUMN` with the full definition and does
      not touch existing rows.
    
    ## Sequences
    
    ```sql
    CREATE SEQUENCE OrderSeq OPTIONS (sequence_kind = 'bit_reversed_positive');
    CREATE TABLE Orders (
      OrderId INT64 NOT NULL DEFAULT (GET_NEXT_SEQUENCE_VALUE(SEQUENCE OrderSeq)),
      Total NUMERIC,
    ) PRIMARY KEY (OrderId);
    ```
    
    - `bit_reversed_positive` is the only kind. The values are unique and spread over the key space, not
      consecutive. `skip_range_min` and `skip_range_max` keep a range free, such as the ids an existing
      table already uses (https://docs.cloud.google.com/spanner/docs/primary-key-default-value).
    - Atlas leaves identity columns out of plans, so use a named sequence and a `DEFAULT` instead of
      `GENERATED BY DEFAULT AS IDENTITY`. `AUTO_INCREMENT` and identity columns without a kind also need the
      `default_sequence_kind` database option, which Atlas does not manage and which cannot be changed once
      set.
    - Option changes plan `ALTER SEQUENCE ... SET OPTIONS`.
    - Spanner cannot drop a sequence that a column default or a view uses.
    
    ## Views
    
    - Spanner requires `SQL SECURITY INVOKER` or `DEFINER` on every view; a SQL schema without it fails
      with ``View `V` is missing the SQL SECURITY clause``.
    - A schema change that would break a view's query fails
      (https://docs.cloud.google.com/spanner/docs/schema-updates#validate-view-definitions).
    - `CREATE OR REPLACE VIEW` drops the grants on the view, and Spanner does not restore them
      (https://docs.cloud.google.com/spanner/docs/create-manage-views). With permissions managed, plan again
      after a view change to grant them back.
    - Views are read-only and cannot be indexed.
    
    ## Change Streams
    
    - Atlas plans any change to a stream as `DROP CHANGE STREAM` and `CREATE CHANGE STREAM`. Dropping a
      stream deletes its change records, and readers of the old stream stop
      (https://docs.cloud.google.com/spanner/docs/change-streams/manage). Change a stream in a hand-written
      migration file, and the schema then plans no change:
    
      ```sql
      ALTER CHANGE STREAM EventsStream SET OPTIONS (retention_period = '3d');
      ALTER CHANGE STREAM SingersBio SET FOR Singers(Name);
      ```
    
      The `statement` rule in `references/migrations.md` flags a planned `DROP CHANGE STREAM`.
    - `retention_period` runs from `1d` to `30d`, 7 days by default. A database holds up to 10 streams, and
      a column can be watched by up to 3 (https://docs.cloud.google.com/spanner/quotas).
    - Spanner refuses to drop a table or column that a stream watches by name. Atlas changes the stream
      first, by recreating it.
    
    ## Row Deletion Policies
    
    - `ROW DELETION POLICY (OLDER_THAN(CreatedAt, INTERVAL 30 DAY))` deletes rows once the `TIMESTAMP`
      column is older than the interval, usually within 72 hours. Rows with a `NULL` timestamp stay
      (https://docs.cloud.google.com/spanner/docs/ttl).
    - A table holds one policy. Atlas plans `ADD`, `REPLACE`, or `DROP ROW DELETION POLICY`.
    - All interleaved children of the table need `ON DELETE CASCADE`, and every foreign key that references
      it needs `ON DELETE CASCADE`. Spanner refuses to drop the policy's column
      (https://docs.cloud.google.com/spanner/docs/ttl/working-with-ttl).
    
    ## Named Schemas
    
    - `CREATE SCHEMA sales` holds tables, views, indexes, foreign keys, and sequences, referenced by their
      qualified names (`sales.Orders`). An index lives in its table's schema, and a schema cannot be dropped
      while it holds objects (https://docs.cloud.google.com/spanner/docs/named-schemas).
    - The default schema is `default` in GoogleSQL HCL and `public` in the PostgreSQL dialect.
    - Keep sequences in the default schema (What Atlas Leaves Out, above).
    
    ## Enterprise Features
    
    | Feature | Edition | Atlas |
    |---------|---------|-------|
    | Search indexes, vector indexes, property graphs | Enterprise or Enterprise Plus | Planned. Vector index options need HCL |
    | Locality groups (tiered storage) | Enterprise or Enterprise Plus | Planned from HCL. The emulator keeps only some of their options |
    | Placements (geo-partitioning, Preview) | Enterprise Plus | Planned from HCL. The emulator treats them as no-ops |
    
    The edition table is https://docs.cloud.google.com/spanner/docs/editions-overview. A placement cannot
    be altered, and a placement key cannot be added to an existing table
    (https://docs.cloud.google.com/spanner/docs/create-manage-data-placements). Spanner Graph is GoogleSQL
    only.
    
    ## PostgreSQL Dialect
    
    A database's dialect is fixed when the database is created. Atlas reads it from the target; plan
    PostgreSQL-dialect databases on `docker://spannerpg/<version>` (`references/dev-database.md`).
    
    What Spanner's PostgreSQL interface leaves out
    (https://docs.cloud.google.com/spanner/docs/reference/postgresql/overview,
    https://docs.cloud.google.com/spanner/docs/reference/postgresql/data-types):
    
    - No triggers, stored functions, extensions, enums, or user-defined types.
    - `int` is `bigint`, and `char` and `timestamp without time zone` do not exist.
    - `numeric`, `float4`, and `jsonb` columns cannot be keys or be indexed: an index on one fails with
      `Cannot reference PG.NUMERIC total in the creation of index`.
    - A numeric default needs a cast, `DEFAULT 0::numeric`. Without it the schema fails with
      `Expected type PG.NUMERIC; found INT64`.
    - Partial indexes accept only `WHERE col IS NOT NULL`.
    
    Atlas on the PostgreSQL dialect:
    
    | Object | What happens | What to do |
    |--------|--------------|------------|
    | `TTL INTERVAL '30 days' ON created_at` | In the schema or in a migration file, planning fails: `is not supported in Spanner PostgreSQL dialect`. Added by hand on the target, the next declarative plan drops it | Keep TTL tables out of Atlas with `exclude`, and manage their TTL by hand |
    | `spanner.commit_timestamp` columns | The first plan works; every later plan fails with `unsupported type` | Declarative: exclude the columns, `exclude = ["*.*.updated_at"]`. Versioned: `migrate diff` cannot plan again, and the same `exclude` plans a `DROP COLUMN` for them |
    
    Tables, interleaving, indexes with `INCLUDE`, checks, stored generated columns, `jsonb` columns,
    sequences with `nextval('seq')` defaults, and `SQL SECURITY INVOKER` views plan and round-trip.
    
  • skills/atlas-spanner/references/security.md6.2 KBd00aaa237692upstream ↗
    # Spanner Security as Code
    
    Database roles and grants, Spanner's fine-grained access control. Spanner has no database users:
    Google Cloud IAM authenticates principals, and a principal acts as a database role to get the role's
    privileges (https://docs.cloud.google.com/spanner/docs/fgac-about). Atlas manages the roles and their
    grants; the IAM bindings that let principals use the roles stay outside Atlas.
    
    ## Turn It On
    
    Roles and permissions are left out of inspection and planning by default, and managing them needs a
    login. If `atlas whoami` shows no login, ask the user to run `atlas login`; a user without an account can
    start a free trial with it.
    
    ```hcl
    env "prod" {
      url = getenv("SPANNER_URL")
      dev = getenv("SPANNER_DEV_URL")
      schema {
        src = "file://schema.sp.hcl"
        mode {
          roles       = true
          permissions = true
        }
      }
    }
    ```
    
    The dev database must be an empty database on a real Spanner instance, not the emulator
    (`references/dev-database.md`, Your Own Dev Database). The emulator parses role and grant statements
    and does nothing with them, so planning against it fails:
    
    | Mode | Error on the emulator |
    |------|-----------------------|
    | `permissions = true` | `iterating table acls: ... Table not found: INFORMATION_SCHEMA.TABLE_PRIVILEGES` |
    | `roles = true` alone | `Abort: the planned state does not match the desired state after applying the file.` |
    | A column grant in a SQL schema | `Emulator does not yet support column level access controls` |
    
    ## Roles and Grants
    
    ```hcl
    role "hr_reader" {
    }
    
    role "hr_writer" {
      member_of = [role.hr_reader]
    }
    
    role "payroll" {
    }
    
    permission {
      to         = role.hr_reader
      for        = table.Employees
      privileges = [SELECT]
    }
    
    permission {
      to         = role.hr_writer
      for        = table.Employees
      privileges = [INSERT, UPDATE, DELETE]
    }
    
    permission {
      to         = role.payroll
      for        = table.Employees.column.Salary
      privileges = [SELECT, UPDATE]
    }
    ```
    
    Atlas plans:
    
    ```sql
    CREATE ROLE `hr_reader`;
    CREATE ROLE `hr_writer`;
    GRANT ROLE `hr_reader` TO ROLE `hr_writer`;
    CREATE ROLE `payroll`;
    GRANT SELECT ON TABLE `Employees` TO ROLE `hr_reader`;
    GRANT DELETE, INSERT, UPDATE ON TABLE `Employees` TO ROLE `hr_writer`;
    GRANT SELECT (`Salary`), UPDATE (`Salary`) ON TABLE `Employees` TO ROLE `payroll`;
    ```
    
    - `for` takes a table, a view, or a column of a table or view, and `privileges` take `SELECT`,
      `INSERT`, `UPDATE`, and `DELETE`. `DELETE` cannot be granted on a column
      (https://docs.cloud.google.com/spanner/docs/fgac-privileges). A `permission` on a schema fails with
      `unsupported change` (a schema modification).
    - Model every grantee as a `role`. The `user` block plans no statement on Spanner, and a `permission`
      whose `to` is a `user` plans `GRANT ... TO ROLE <user>` for a role that does not exist.
    - A role that holds privileges cannot be dropped, so Atlas plans each `REVOKE` before the `DROP ROLE`
      (https://docs.cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language).
    - A database holds up to 100 roles (https://docs.cloud.google.com/spanner/docs/fgac-about). The names
      `public` and those starting with `spanner_` are reserved in GoogleSQL, and names starting with `pg_` in
      the PostgreSQL dialect.
    - The system roles `public`, `spanner_info_reader`, and `spanner_sys_reader` exist in every database
      and cannot be dropped. Every role inherits the privileges of `public`
      (https://docs.cloud.google.com/spanner/docs/fgac-system-roles).
    - Grants that `permission` cannot express, such as `SELECT` on a change stream, `EXECUTE` on its read
      function, `SELECT` and `UPDATE` on a sequence, or `USAGE` on a schema, go in hand-written migration
      files. `SELECT` on a table does not grant `SELECT` on the change stream that watches it.
    
    ## Views with Definer's Rights
    
    A view with `security = DEFINER` lets a role read it with a grant on the view alone, without grants on
    the tables it reads (https://docs.cloud.google.com/spanner/docs/views):
    
    ```hcl
    view "EmployeeNames" {
      schema   = schema.default
      as       = "SELECT e.Id, e.Name FROM Employees AS e"
      security = DEFINER
    }
    
    permission {
      to         = role.directory
      for        = view.EmployeeNames
      privileges = [SELECT]
    }
    ```
    
    An emulator older than 1.5.56 rejects `SQL SECURITY DEFINER` with `Expecting 'INVOKER' but found
    'DEFINER'` (`references/dev-database.md`, Docker Dev URLs).
    
    ## IAM Outside Atlas
    
    Who may act as a role is an IAM binding, not DDL
    (https://docs.cloud.google.com/spanner/docs/configure-fgac):
    
    - Grant the principal `roles/spanner.fineGrainedAccessUser`, and `roles/spanner.databaseRoleUser`
      with a condition that names the roles it may use:
      `resource.type == "spanner.googleapis.com/DatabaseRole" && resource.name.endsWith("/hr_reader")`.
      Without a condition, the principal can act as every role.
    - A principal that also holds database-level IAM permissions, such as `roles/spanner.databaseUser`, uses
      them whenever it connects without naming a role, which bypasses fine-grained access control
      (https://docs.cloud.google.com/spanner/docs/access-with-fgac). Give application principals the
      fine-grained roles only.
    - Atlas itself connects with database-level IAM permissions, so it sees the whole schema: it needs to
      read and update the schema (`spanner.databases.getDdl`, `spanner.databases.updateDdl`), and to read and
      write the revisions table. `roles/spanner.databaseUser` covers both
      (https://docs.cloud.google.com/spanner/docs/iam).
    - Database exports do not include roles and privileges
      (https://docs.cloud.google.com/spanner/docs/fgac-about). A database restored from an export needs
      `atlas schema apply` with roles enabled to get them back.
    
    ## Errors
    
    | Error | Fix |
    |-------|-----|
    | `Table not found: INFORMATION_SCHEMA.TABLE_PRIVILEGES` | The target or the dev database is the emulator: use a real Spanner database |
    | `Emulator does not yet support column level access controls` | Plan column grants on a real Spanner dev database |
    | `the planned state does not match the desired state` with roles enabled | The dev database is the emulator: use a real Spanner database |
    | A grant to a `user` fails because the role does not exist | Declare the grantee as a `role` |
    | `unsupported change` (a schema modification) | A `permission` on a schema: write schema grants by hand |
    
  • skills/atlas-spanner/references/testing.md8.7 KBe2b97a6e5e14upstream ↗
    # Testing Spanner Schemas and Migrations
    
    Atlas runs tests on the dev database. The test syntax, every command, and examples are in
    `../atlas/references/testing.md`; this file covers how to use them on Spanner. Testing needs
    `atlas login`. If `atlas whoami` shows no login, ask the user to run `atlas login`; a user without an
    account can start a free trial with it.
    
    ## Use Migration Tests
    
    `atlas schema test` does not run on Spanner: it creates the schema on the dev database inside a
    transaction, and every case fails during setup:
    
    ```
    -- FAIL: balance_check (0µs)
        schema.test.hcl:1:
            	Error:      	unexpected error during test setup: spanner: code = "FailedPrecondition", desc = "cannot execute DDL as part of a transaction"
    ```
    
    `atlas migrate test` works. Write every test as a `test "migrate"` case: migrate to a version, seed rows,
    and check the result. The test syntax is the same as in schema tests, plus a `migrate` block.
    
    ## Test Every Change
    
    A schema or migration change is done when its tests pass:
    
    1. After editing the schema, run `atlas schema validate --env <name>`.
    2. Lint the change, so the analyzers and custom rules check it, and so a statement Spanner rejects
       fails here instead of in production: `atlas migrate lint --env <name> --latest 1`, or in the
       declarative workflow the plan of `atlas schema apply --env <name> --dry-run`
       (`references/migrations.md`).
    3. Add or update a `test "migrate"` case for what the change touches: a check, a unique or
       `NULL_FILTERED` index, an interleaved delete, a foreign key, a generated column, a default, a
       sequence, or a view, and every migration that moves, converts, or backfills data.
    4. Run the new case alone with `--run <case>`, and fix the logic until it passes.
    5. Run the whole suite: `atlas migrate test --env <name>`.
    6. Report the cases you added and that they pass. If the tests could not run, say why.
    
    `migrate test` also catches a hand-written file without `-- atlas:txmode none`, which `migrate lint` and
    `migrate validate` accept and `migrate apply` then fails on (`references/migrations.md`).
    
    The env lists the test files next to its dev database (`references/dev-database.md`):
    
    ```hcl
    env "dev" {
      dev = "docker://spanner/1.5.58"
      migration {
        dir = "file://migrations"
      }
      test {
        migrate {
          src = ["migrate.test.hcl"]
        }
      }
    }
    ```
    
    ## Declarative Projects
    
    A project without a migration directory tests its schema through a throwaway one: generate a single
    migration from the schema, and run the cases against it. The test file takes the version as a variable:
    
    ```hcl
    variable "version" {
      type    = string
      default = ""
    }
    
    env "dev" {
      src = "file://schema.sql"
      dev = "docker://spanner/1.5.58"
      test {
        migrate {
          src = ["schema.test.hcl"]
          vars = {
            version = var.version
          }
        }
      }
    }
    ```
    
    ```hcl
    # schema.test.hcl
    variable "version" {
      type = string
    }
    
    test "migrate" "balance_check" {
      migrate {
        to = var.version
      }
      catch {
        sql   = "INSERT INTO Customers (CustomerId, Email, Balance) VALUES ('c1', '[email protected]', -1)"
        error = "BalanceNonNegative"
      }
    }
    ```
    
    ```bash
    dir=$(mktemp -d)
    atlas migrate diff --env dev --dir "file://$dir" snapshot
    version=$(ls "$dir" | grep _snapshot.sql | cut -d_ -f1)
    atlas migrate test --env dev --dir "file://$dir" --var version="$version"
    rm -rf "$dir"
    ```
    
    `--var` sets a variable of `atlas.hcl`, not of the test file: the test file gets it through `vars` in
    the env's `test` block, as above. Without that, the run fails with
    `missing value for required variable "version"`.
    
    ## Why It Matters More on Spanner
    
    - Spanner runs each DDL statement as its own schema change, so a file or a plan that fails halfway
      stays half applied (`references/migrations.md`). A migration test fails on the dev database first.
    - Constraints that Spanner checks against existing rows, such as `NOT NULL`, a shorter `STRING(n)`, a
      unique index, a foreign key, or a check, pass on an empty database. Only seeded rows show the failure.
    - The emulator is not production. It does not enforce mutation limits or quotas, and it accepts some
      SQL that production rejects (`references/dev-database.md`, What the Emulator Does Not Do). A data
      migration that passes its test can still exceed the 80,000 mutations one production DML statement
      allows (`references/migrations.md`, Data Changes).
    - The emulator runs one read-write transaction or schema change at a time, so tests on one emulator
      run one after another.
    
    ## What to Write
    
    Each case starts from an empty database. Migrate to the version before the change, seed rows, migrate to
    the version under test, and check the data (https://atlasgo.io/guides/testing/data-migrations):
    
    ```hcl
    test "migrate" "email_not_null" {
      migrate {
        to = "20261001000001"
      }
      exec {
        sql = "INSERT INTO Users (Id, Email) VALUES (1, NULL), (2, '[email protected]')"
      }
      migrate {
        to = "20261001000002"
      }
      exec {
        sql    = "SELECT COUNT(*) FROM Users WHERE Email IS NULL"
        output = "0"
      }
    }
    ```
    
    Here version 2 backfills `Email` before it makes the column `NOT NULL`. Without the backfill, the test
    fails where production would.
    
    Write a migration test for each migration that:
    
    - Makes a column `NOT NULL` (`MF104`): seed `NULL` rows.
    - Shortens a `STRING(n)` or `BYTES(n)`: seed a value longer than the new length. Lint does not report
      this change.
    - Adds a unique index (`MF101`): seed duplicates, and two rows with `NULL`. A plain `UNIQUE` index
      treats `NULL`s as equal and rejects the second row; a `UNIQUE NULL_FILTERED` index skips `NULL` rows
      (`references/objects.md`, Indexes).
    - Adds a foreign key or a check: seed rows that break it.
    - Backfills or moves data, such as the add, copy, and drop that replaces a type change: compare the rows
      after the migration.
    
    And cases that exercise the schema:
    
    ```hcl
    test "migrate" "interleaved_cascade" {
      migrate {
        to = "20261001000002"
      }
      exec {
        sql = "INSERT INTO Customers (CustomerId, Email) VALUES ('c1', '[email protected]')"
      }
      exec {
        sql = "INSERT INTO Orders (CustomerId, Total) VALUES ('c1', 10), ('c1', 5)"
      }
      exec {
        sql    = "SELECT CAST(Total AS STRING) FROM CustomerTotals WHERE CustomerId = 'c1'"
        output = "15"
      }
      exec {
        sql = "DELETE FROM Customers WHERE CustomerId = 'c1'"
      }
      exec {
        sql    = "SELECT COUNT(*) FROM Orders"
        output = "0"
      }
    }
    
    test "migrate" "sequence_keys_are_spread" {
      migrate {
        to = "20261001000002"
      }
      exec {
        sql = "INSERT INTO Customers (CustomerId, Email) VALUES ('c1', '[email protected]')"
      }
      exec {
        sql = "INSERT INTO Orders (CustomerId, Total) VALUES ('c1', 1), ('c1', 2)"
      }
      exec {
        sql    = "SELECT COUNTIF(OrderId > 1000000) FROM Orders"
        output = "2"
      }
    }
    ```
    
    A bit-reversed sequence hands out large, scattered values, not 1, 2, 3, so assert ranges or uniqueness,
    never exact ids.
    
    ## Matching Errors
    
    `catch` matches the error text of a statement that writes, such as an `INSERT`, `UPDATE`, or `DELETE`.
    It does not see a failing `SELECT`: Spanner reports a query error only when the rows are read, so
    `catch` fails with `an error is expected, but none occurred` even for a column that does not exist.
    Check what a migration removed with `exec` and `output` over `INFORMATION_SCHEMA`:
    
    ```hcl
      exec {
        sql    = "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Users' AND COLUMN_NAME = 'Nick'"
        output = "0"
      }
    ```
    
    Match the constraint or index name, or a stable phrase, not the whole message. The emulator reports:
    
    | Violation | Error contains |
    |-----------|----------------|
    | Check constraint | ``Check constraint `P`.`VPositive` is violated for key {Int64(1)}`` |
    | `NOT NULL` column left out of an `INSERT` | `does not specify a non-null value for NOT NULL column: Name` |
    | `NOT NULL` column set to `NULL` | `Cannot specify a null value for column: Users.Status` |
    | Unique index | `UNIQUE violation on index PByName` |
    | Duplicate primary key | `due to previously existing row` |
    | Interleaved child without a parent row | `Insert failed because key was not found in parent table` |
    | Foreign key | ``Foreign key `FK_FP` constraint violation`` |
    | Value longer than `STRING(n)` | `New value exceeds the maximum size limit for this column` |
    
    Production words some errors differently, so name constraints and assert on the name.
    
    ## CI
    
    Run tests where the extended build of Atlas is installed, with the install script and
    `ATLAS_FLAVOR="spanner"`, or from the `arigaio/atlas:latest-extended` image. A `docker://spanner` dev URL
    needs a Docker daemon. Without one, run the emulator as a service container,
    `gcr.io/cloud-spanner-emulator/emulator:1.5.58` on ports 9010 and 9020, create an instance and an empty
    database in it, and point `dev` at that database (`references/dev-database.md`, Connection URLs). Pin
    the same emulator release locally and in CI.
    
  • README.mdupstream ↗

    Contents are not inlined in the catalog. Open the upstream file.

Plain-text copy, no login: /skill-bundles/ariga-atlas-skills-atlas-spanner.md

// REPO STATS

8.9k stars
256 open issues
Last commit: 5d ago