Skip to main content

ratel schema

Generate SQL schema from Go table definitions.

Usage

ratel schema [flags]

Flags

FlagShortDescription
--package-pGo package path containing models (required)
--tables-tTable variable names to include (comma-separated)
--discover-dAuto-discover tables from source files
--output-oOutput SQL file (default: schema.sql)

Examples

# Auto-discover all tables
ratel schema -p github.com/myapp/models --discover -o schema.sql

# Specific tables
ratel schema -p github.com/myapp/models -t Users,Orders,Products -o schema.sql

Output

Generates a .sql file with:

  1. CREATE SCHEMA IF NOT EXISTS statements
  2. CREATE TABLE statements in topological order (respecting FK dependencies)
  3. CREATE INDEX statements
  4. Post-statements (RLS, grants, etc.)