Multi object rename convergence

From CarlosCaPe/octorato · View interactive version

Multi object rename convergence is an AI agent skill from the GitHub repository CarlosCaPe/octorato. Multi-Object Rename Convergence

How to use this skill

Skill file

Multi-Object Rename Convergence

What

Renaming a table and cascading that rename through all dependent objects:

FK columns across N child tables, views, stored procedures, indexes, and

constraints. A full-stack rename that goes far beyond a single column rename.

Why

Renaming a table touches every layer of the schema. Unlike a column rename

(Skill #05, metadata-only, no dependents break), a table rename has a blast

radius that includes:

How

Phase 1: Inventory all dependents

-- Find all FK references to the old table
SELECT conname, conrelid::regclass AS child_table
FROM pg_constraint
WHERE confrelid = 'public."Scribe"'::regclass;

-- Find all views referencing the old table
SELECT viewname FROM pg_views
WHERE definition LIKE '%"Scribe"%';

-- Find all procedures referencing the old table
SELECT proname FROM pg_proc
WHERE prosrc LIKE '%"Scribe"%';

Phase 2: Rename the table

ALTER TABLE public."Scribe" RENAME TO "Recording";

Phase 3: Rename FK columns in child tables

-- In each child table, rename the FK column
ALTER TABLE public."ReportWords"
    RENAME COLUMN "ScribeId" TO "RecordingId";

Phase 4: Rebuild views and procedures

Use pg_get_functiondef (Skill #06) for procedures, and CREATE OR REPLACE VIEW

for views, replacing all references to the old name.

Phase 5: Rename indexes and constraints

ALTER INDEX "IX_Scribe_HospitalId" RENAME TO "IX_Recording_HospitalId";
ALTER TABLE public."Recording"
    RENAME CONSTRAINT "PK_Scribe" TO "PK_Recording";

When to Use

Where We Used It

converged FK columns, views, procedures, and indexes

names and definitions

Related Skills

Gotchas

views/aliases

rebuilds -> index/constraint renames


Category: DDL | Origin: ,

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.