Works with the AI Agents you already use

    Schema Foreign Key Repair Planner AI

    by Pitiko Studio

    1

    Inventory orphan references and plan non-destructive repairs. Built for database engineers and platform teams, with

    $9.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Schema Foreign Key Repair Planner AI

    Schema Foreign Key Repair Planner AI

    Example session with this skill installed

    Analyze these orphan records in the 'orders' table (parent 'customers' is missing IDs 502, 588) for PostgreSQL 15. Plan a non-destructive repair and provide the evidence ledger.

    • Read your context and instructions
    • Compiled the schema foreign key

    Illustrative example using synthetic inputs.

    The analysis of the 'orders' table orphan references is complete. I have identified the necessary transitions and constructed a repair sequence based on PostgreSQL 15 semantics.

    Evidence and Status Ledger

    Item IDCurrent StateSourceStatusOwnerNext Checkpoint
    ORD-502Orphaned (Parent 502 missing)orders_dump_v1.sqlPlannedDB_EngVerify synthetic parent
    ORD-588Orphaned (Parent 588 missing)orders_dump_v1.sqlPlannedDB_EngVerify synthetic parent
    FK_CUST_IDViolatedschema_v2.sqlReview RequiredPlatform_LeadLock impact analysis

    Proposed Repair Sequence (Non-Destructive)

    -- Step 1: Create a staging table for orphans to prevent data loss
    CREATE TABLE orders_orphans_backup AS 
    SELECT * FROM orders WHERE customer_id IN (502, 588);
    
    -- Step 2: Insert synthetic parent records to satisfy constraint temporarily
    INSERT INTO customers (id, name, status) 
    VALUES (502, 'Placeholder_Orphan_502', 'inactive'),
           (588, 'Placeholder_Orphan_588', 'inactive')
    ON CONFLICT DO NOTHING;
    
    -- Step 3: Validate constraint readiness (NOT VALID mode for Postgres)
    ALTER TABLE orders ADD CONSTRAINT fk_orders_customer 
    FOREIGN KEY (customer_id) REFERENCES customers(id) NOT VALID;
    
    -- Step 4: Final validation
    ALTER TABLE orders VALIDATE CONSTRAINT fk_orders_customer;
    

    Validation Summary

    • Observed: Identified specific orphan IDs (502, 588) from provided source dump.
    • Planned: Synthetic parent insertion and NOT VALID constraint application.
    • Not Run: Actual execution on production; lock duration monitoring.

    Next steps

    1. Review the synthetic parent record attributes to ensure they meet application-level validation.
    2. Execute the staging table backup in a staging environment to confirm row counts.
    3. Obtain Platform Lead approval for the ALTER TABLE lock window.
    orders_dump_v1.sql

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Schema migrations and foreign key constraints are high-risk operations that often fail due to unexpected orphan records or locking issues. This skill provides a structured framework for database engineers to inventory broken references and design non-destructive repair plans. It replaces guesswork with an evidence-based ledger that links every repair action to specific source data.

    What it does

    • Inventory orphan references by identifying records that violate referential integrity without a valid parent.
    • Generate repair plans using non-destructive sequences that prioritize data safety and uptime.
    • Track evidence status through a ledger that connects every proposed change to observed source records.
    • Analyze lock impacts by evaluating how schema changes will affect transaction and replication traces.
    • Define rollback criteria for every material recommendation to ensure a safe exit path.

    How it works

    1. Provide the affected schema items, current/target states, and a representative source record or query plan.
    2. The skill normalizes identifiers and establishes transaction semantics based on your database engine and version.
    3. It generates an evidence and status ledger, marking items as observed, derived, or conflicted.
    4. It performs a boundary check to identify missing evidence or potential edge cases in the migration sequence.

    Frameworks & tools

    Built for database platform teams working with SQL-based systems. It supports analysis for specific engine versions by referencing official documentation and SQL standard guidance when public URLs are provided.

    Why this beats prompting it yourself

    Generic prompts often suggest destructive DELETE or TRUNCATE operations that ignore replication lag or application logic. This skill enforces a strict evidence-based methodology that requires transaction impact analysis and explicit rollback conditions for every proposed change.

    Use cases

    • Planning the introduction of a new foreign key constraint on a legacy table with dirty data.
    • Identifying and documenting orphan records across microservice database boundaries.
    • Preparing a reviewable migration plan for a high-traffic production schema change.
    • Creating reproducible SQL fixtures for testing schema repairs in disposable environments.

    Known limitations

    Does not execute mutating SQL or perform live database writes. It cannot verify query timings or backup integrity unless that data is explicitly supplied in the context.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Frequently Asked Questions

    Inventory orphan references and plan non-destructive repairs. Built for database engineers and platform teams, with

    This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

    Connect your AI agent to Agensi through MCP, then ask it to use Schema Foreign Key Repair Planner AI on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.