ratel schema
Generate SQL schema from Go table definitions.
Usage
ratel schema [flags]
Flags
| Flag | Short | Description |
|---|---|---|
--package | -p | Go package path containing models (required) |
--tables | -t | Table variable names to include (comma-separated) |
--discover | -d | Auto-discover tables from source files |
--output | -o | Output 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:
CREATE SCHEMA IF NOT EXISTSstatementsCREATE TABLEstatements in topological order (respecting FK dependencies)CREATE INDEXstatements- Post-statements (RLS, grants, etc.)