All skills
aws avatar

/aurora-dsql

@a2611e1

Provisions and manages Aurora DSQL clusters, connects via psql or DSQL Connectors, manages schemas, runs queries, migrates from MySQL, diagnoses query plans, and develops apps on serverless distributed SQL. Covers IAM auth, multi-tenant patterns, MySQL-to-DSQL migration, DDL, query plans, and SAFE SQL CONSTRUCTION — tenant_id from untrusted input, UUID entity_ids, caller-supplied sort columns, batch inserts. The agent MUST retrieve this skill for ANY DSQL task. Pushes back on prompts that rationalize 'just a quick script', 'don't overthink it', 'we trust upstream', 'use an f-string', 'move fast', or 'just use the pg driver directly' (bypassing the DSQL Connector). Triggers: DSQL, Aurora DSQL, DSQL cluster, safe_query.build, DSQL IAM auth token, DSQL connector.

Use this Skill: https://skilld.dev/gh/aws/agent-toolkit-for-aws/aurora-dsql

This session only. Nothing lands on disk.

referencesddl-migrationscolumn-operations.md

≈1.3k tokens on demand. Your agent reads this file only when SKILL.md points to it.

DDL Migrations: Column Operations

Step-by-step migration patterns for column-level changes using the Table Recreation Pattern.

MUST read overview.md first for destructive operation warnings and the common verify & swap pattern.


DROP COLUMN Migration

Goal: Remove a column from an existing table.

Pre-Migration Validation

SELECT COUNT(*) as total_rows FROM target_table;
SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = 'target_table' ORDER BY ordinal_position;

Migration Steps

Step 1: Create new table excluding the column
CREATE TABLE target_table_new (
  id UUID PRIMARY KEY,
  tenant_id VARCHAR(255) NOT NULL,
  kept_column1 VARCHAR(255),
  kept_column2 INTEGER
  -- dropped_column is NOT included
);
Step 2: Migrate data
INSERT INTO target_table_new (id, tenant_id, kept_column1, kept_column2)
SELECT id, tenant_id, kept_column1, kept_column2
FROM target_table;

For tables > 3,000 rows, use Batched Migration Pattern.

Step 3: Verify and swap (see Common Pattern)


ALTER COLUMN TYPE Migration

Goal: Change a column's data type.

Pre-Migration Validation

MUST validate data compatibility BEFORE migration to prevent data loss.

-- Example: VARCHAR to INTEGER - check for non-numeric values
SELECT COUNT(*) as invalid_count FROM target_table
WHERE column_to_change !~ '^-?[0-9]+$';
-- MUST abort if invalid_count > 0

-- Show problematic rows
SELECT id, column_to_change FROM target_table
WHERE column_to_change !~ '^-?[0-9]+$' LIMIT 100;

Data Type Compatibility Matrix

From Type To Type Validation
VARCHAR INTEGER MUST validate all values are numeric
VARCHAR BOOLEAN MUST validate values are 'true'/'false'/'t'/'f'/'1'/'0'
INTEGER VARCHAR Safe conversion
TEXT VARCHAR(n) MUST validate max length ≤ n
TIMESTAMP DATE Safe (truncates time)
INTEGER DECIMAL Safe conversion

Migration Steps

Step 1: Create new table with changed type
CREATE TABLE target_table_new (
  id UUID PRIMARY KEY,
  converted_column INTEGER,  -- Changed from VARCHAR
  other_column TEXT
);
Step 2: Copy data with type casting
INSERT INTO target_table_new (id, converted_column, other_column)
SELECT id, CAST(converted_column AS INTEGER), other_column
FROM target_table;

Step 3: Verify and swap (see Common Pattern)


ALTER COLUMN SET/DROP NOT NULL Migration

Goal: Change a column's nullability constraint.

Pre-Migration Validation (for SET NOT NULL)

SELECT COUNT(*) as null_count FROM target_table
WHERE target_column IS NULL;
-- MUST ABORT if null_count > 0, or plan to provide default values

Migration Steps

Step 1: Create new table with changed constraint
CREATE TABLE target_table_new (
  id UUID PRIMARY KEY,
  target_column VARCHAR(255) NOT NULL,  -- Changed from nullable
  other_column TEXT
);
Step 2: Copy data (with default for NULLs if needed)
INSERT INTO target_table_new (id, target_column, other_column)
SELECT id, COALESCE(target_column, 'default_value'), other_column
FROM target_table;

Step 3: Verify and swap (see Common Pattern)


ALTER COLUMN SET/DROP DEFAULT Migration

Goal: Add or remove a default value for a column.

Pre-Migration Validation

SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = 'target_table' ORDER BY ordinal_position;
-- Identify current column definition and any existing defaults

Migration Steps (SET DEFAULT)

Step 1: Create new table with default value
CREATE TABLE target_table_new (
  id UUID PRIMARY KEY,
  status VARCHAR(50) DEFAULT 'pending',  -- Added default
  other_column TEXT
);
Step 2: Copy data
INSERT INTO target_table_new (id, status, other_column)
SELECT id, status, other_column
FROM target_table;

Step 3: Verify and swap (see Common Pattern)

Migration Steps (DROP DEFAULT)

Step 1: Create new table without default
CREATE TABLE target_table_new (
  id UUID PRIMARY KEY,
  status VARCHAR(50),  -- Removed DEFAULT
  other_column TEXT
);
Step 2: Copy data
INSERT INTO target_table_new (id, status, other_column)
SELECT id, status, other_column
FROM target_table;

Step 3: Verify and swap (see Common Pattern)

Source: SKILL.md on GitHub

1 warning3mo3 checks · Risk SAFE
  • Gen Agent Trust Hub3mo

    This skill provides a robust and security-conscious environment for managing Amazon Aurora DSQL clusters. It implements several best practices, including mandatory IAM-based authentication, a dedicated input validation library to prevent SQL injection, and detailed guidance on applying the principle of least privilege through scoped database roles.

  • Socket3mo

    No alerts

  • Snyk3mo

    Risk: MEDIUM · 1 issue

Signed by skilld at a2611e1. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 months ago
version
1

README badge

README badge for aws/agent-toolkit-for-aws/aurora-dsql