supabase-schema-tool
v1.0.1
Published
A CLI tool that organizes a PostgreSQL or Supabase SQL schema export into a clean directory structure.
Maintainers
Readme
Supabase Schema Tool
PostgreSQL & Supabase Schema Organizer
Supabase Schema Tool is a lightweight command-line utility that takes a PostgreSQL or Supabase SQL schema dump file and automatically organizes it into clean, dedicated folders for tables, functions, views, indexes, RLS policies, triggers, types, and extensions.
Features
- Automatic Classification — Sorts tables, functions, views, indexes, RLS policies, triggers, types, and extensions into dedicated subdirectories.
- Table Statement Merging — Automatically pairs
ALTER TABLEstatements with their parentCREATE TABLEdefinitions. - Metadata Generation — Creates a machine-readable
manifest.jsonand an auto-generated summaryREADME.md. - Safe & Non-Destructive — Extracts database objects verbatim without altering or inventing SQL statements.
Installation
Install globally via npm:
npm install -g supabase-schema-toolOr run directly using npx:
npx supabase-schema-tool schema.sqlUsage & Commands
# Organize SQL schema into default ./schema_output directory
split-schema schema.sql
# Specify a custom output directory
split-schema schema.sql --output ./database
split-schema schema.sql -o ./database
# Enable verbose debug logging
split-schema schema.sql --verbose
# Display help information
split-schema --help
split-schema -h
# Display version number
split-schema --version
split-schema -vNote: You can also run commands using
supabase-schema-toolornpx supabase-schema-tool.
Output Structure
schema_output/
├── tables/ # CREATE TABLE + ALTER TABLE statements
├── functions/ # CREATE FUNCTION / PROCEDURE statements
├── views/ # CREATE VIEW / MATERIALIZED VIEW statements
├── indexes/ # CREATE INDEX statements
├── policies/ # CREATE POLICY statements
├── triggers/ # CREATE TRIGGER statements
├── types/ # CREATE TYPE statements
├── extensions/ # CREATE EXTENSION statements
├── misc.sql # All other statements (SET, GRANT, REVOKE, COMMENT, etc.)
├── manifest.json # Generation metadata
└── README.md # Summary reportSupported Input
- PostgreSQL schema exports (
pg_dump) - Supabase CLI schema exports (
supabase db dump) - Any valid PostgreSQL DDL
.sqlfile
