db-verify-order

Validates DDL statement ordering in SQL migration files to prevent dependency errors.

3|Updated Feb 7, 2026
One-click install
npx skills add https://github.com/gabrielnsmnto/kord-aios --skill db-verify-order-gabrielnsmnto
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: db-verify-order
Source: https://github.com/gabrielnsmnto/kord-aios/tree/main/src/features/builtin-skills/kord-aios/database/db-verify-order
Command: npx skills add https://github.com/gabrielnsmnto/kord-aios --skill db-verify-order-gabrielnsmnto

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? SQL migrations fail when DDL statements execute in the wrong order, such as functions referencing tables that do not exist yet or RLS policies created before their tables. This Skill lints migration files for safe execution order before you run them against a database. ## Core Features & Use Cases - DDL Section Extraction: Parses migration files with awk to identify extensions, tables, functions, triggers, RLS policies, and views along with their line numbers. - Heuristic Order Checks: Detects common problems like functions defined before tables, RLS before table creation, and triggers before their functions. - Dependency Pattern Guidance: Documents correct ordering for foreign keys, functions calling functions, views on views, and RLS policies using helper functions. - Use Case: Before applying a PostgreSQL migration that creates tables, functions, triggers, and RLS policies, run this check to catch ordering mistakes in seconds instead of hitting a failed migration and partial schema state. ## Quick Start Verify the DDL execution order of my migration file at supabase/migrations/20240101_init.sql and report any ordering issues.

Frequently Asked Questions about db-verify-order

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check SQL migration file ordering before running it?▼

Run the verify-order check on the migration file path. It extracts DDL sections with awk, compares actual order against the recommended sequence (extensions, tables, functions, triggers, RLS, views), and reports violations with line numbers.

What is the correct order for DDL statements in PostgreSQL migrations?▼

The recommended order is: CREATE EXTENSION first, then CREATE TABLE with constraints, then CREATE FUNCTION, then CREATE TRIGGER, then ENABLE RLS and CREATE POLICY, and finally CREATE VIEW. This ensures every object exists before it is referenced.

Why does my migration fail with relation does not exist errors?▼

This error occurs when a function, view, trigger, or policy references a table that has not been created yet in the migration file. Reorder the file so referenced objects are defined before the statements that use them.

Does this ordering check require a database connection?▼

No, the check is purely static analysis of the migration file using shell text processing. It runs in under a second without connecting to any database, making it safe for CI pipelines.

What are the limitations of heuristic DDL order checking?▼

Heuristic checks miss complex cross-file dependencies, dynamic SQL, and subtle type dependencies since they are not a full SQL parser. For complete validation, follow up with a dry-run execution of the migration against a real database.