Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

spanner-relational-to-graph

БесплатноБез исполняемых скриптовНе проверен

Analyzes existing Spanner relational schemas on Google Cloud (DDL, foreign keys, interleaved tables, and junction tables) and generates `CREATE PROPERTY…

googleот google★ 25 380 звёзд на GitHub

Об этом скилле

Spanner Relational-to-Property-Graph Schema Conversion

Convert an existing Spanner relational schema into a valid, production-ready CREATE OR REPLACE PROPERTY GRAPH DDL definition while keeping existing relational tables intact.

Usage Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read and follow the instructions in Usage Attribution.

Prerequisites & Cloud Environment Setup

When inspecting a live Spanner instance or verifying DDL (see spanner-basics for general Spanner instance provisioning and MCP setup):

  1. Google Cloud SDK (gcloud): Ensure the CLI is installed (see Install the Google Cloud SDK).
  2. Project, Billing & API: Verify an active Google Cloud project with billing enabled (required even when provisioning a free trial instance) is configured (gcloud config set project {project_id}) and, after the user confirms, enable the Spanner API (gcloud services enable spanner.googleapis.com). Ask the user before changing the active project, billing, or enabled APIs, or creating or deleting instances, because these commands change the user's Google Cloud environment and can incur costs.
  3. Authentication & IAM Roles: Authenticate via gcloud auth login or gcloud auth application-default login (or GOOGLE_APPLICATION_CREDENTIALS for service accounts). Listing instances/databases requires roles/spanner.viewer, inspecting DDL requires roles/spanner.databaseReader, and applying CREATE VIEW / CREATE PROPERTY GRAPH DDL requires roles/spanner.databaseAdmin.
  4. Instance Region & Pricing: For sandbox test instances, default to regional-us-central1 unless specified otherwise (see Spanner instance configurations, Google Cloud locations, Spanner pricing, and Google Cloud pricing).

Core Principles

  1. Zero Data Duplication: Spanner Graph maps existing relational tables or SQL views directly into graph nodes and edges via CREATE PROPERTY GRAPH metadata—without copying data or breaking existing SQL applications.
  2. Preserve Existing Tables: Treat all existing relational tables as read-only inputs. Do not drop, rename, or alter existing columns or primary keys when adding a property graph view. If an implicit relationship requires key transformation (for example, unnesting an array or casting mismatched key types), define a new SQL bridge view (CREATE VIEW ... SQL SECURITY INVOKER AS ... by default, or SQL SECURITY DEFINER when row-level access control is needed) and bind the edge or node to that view.
  3. 100% Table Accounting: Account for every relational table in the input schema—either mapped into NODE TABLES / EDGE TABLES or explicitly listed as excluded (such as pure system audit logs, schema migration state tables, or unlinked lookup tables).

Step-by-Step Conversion Workflow

Step 1: Discover or Parse the Relational Schema

  • If the user provides DDL statements in the prompt, parse all CREATE TABLE, PRIMARY KEY, INTERLEAVE IN PARENT, and FOREIGN KEY definitions directly.

  • If the user provides a live Spanner instance and database ID (or a Google Cloud Console URL containing instances/{instance_id}/databases/{database_id}?project={project_id}), extract project, instance, and database and retrieve the live DDL using the read-only gcloud command:

    gcloud spanner databases ddl describe {database_id} \
      --instance={instance_id} \
      --project={project_id}
    
    • Live-Database Safety Rule: gcloud spanner databases ddl describe is read-only and safe to run automatically, whereas applying CREATE VIEW or CREATE OR REPLACE PROPERTY GRAPH via gcloud spanner databases ddl update mutates the live database—always ask for explicit user confirmation before running gcloud spanner databases ddl update (and state this confirmation requirement clearly in your response even if ddl describe fails due to missing credentials or network access).
    • See references/cloud-spanner-guide.md for environment discovery, emulator setup, and verification workflows.

Step 2: Classify Relational Tables into Nodes and Edges

Apply the structural classification rules in references/patterns.md:

  1. Core Entity Tables -> NODE TABLES:
    • Tables representing domain nouns (Users, Accounts, Products, Devices, Documents) become node tables.
    • Use the table's full PRIMARY KEY as the node KEY (...).
  2. **Pure or Attributed M:N Junction Tables -> `ED
Полный SKILL.md на GitHub

Установить spanner-relational-to-graph в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/attribution.mdreferences/cloud-spanner-guide.mdreferences/gql-cheat-sheet.mdreferences/patterns.mdreferences/spanner-graph-ddl-syntax.mdreferences/structural-invariants.mdreferences/synthesized-conversions.md

FAQ

Что делает скилл spanner-relational-to-graph?

Analyzes existing Spanner relational schemas on Google Cloud (DDL, foreign keys, interleaved tables, and junction tables) and generates `CREATE PROPERTY GRAPH` DDL statements (`NODE TABLES`, `EDGE TABLES`) without modifying underlying relational tables. Use when mapping existing Spanner tables to a Spanner Graph, identifying node and edge candidates from relational tables, creating SQL bridge views for implicit `ARRAY`/`JSON` or type-mismatched relationships, mapping polymorphic or self-referential tables, or troubleshooting `CREATE PROPERTY GRAPH` DDL compiler errors. Don't use for greenfield physical table design (use spanner-graph-schema-best-practices) or tuning slow ISO GQL queries (use spanner-graph-query-tuning).

Как установить скилл spanner-relational-to-graph?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл spanner-relational-to-graph запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить spanner-relational-to-graph с