Schema Forge for VS Code
Official VS Code and Open VSX extension for the Schema Forge DSL (.sf).
Build and manage Schema Forge projects directly in your editor with native language support and command integration.
Website: schemaforge.xuby.cl
👉 Install from Visual Studio Marketplace
👉 Install from Open VSX
Why use this extension
- Native support for
.sf files
- Syntax highlighting for tables, columns, defaults, indexes, views, and RLS policies
- Built-in snippets for faster schema authoring
- Command Palette actions for core workflows
- Automatic prompt to initialize missing Schema Forge project structure
What's New in 0.6.x
Migration planning & preview workflows
- Schema Forge: Plan — Run migration plan preview with human-readable operation lines
- Schema Forge: Preview — Run migration preview via alias flow
- Status bar menu updates — Includes the new planning and preview actions alongside existing commands
- Improved Visual Diff UX — Clearer operation descriptions for index, policy, and view changes
Phase 1: CLI Commands
Open the Command Palette and run:
Schema Forge: Init — Initializes a new Schema Forge project
Schema Forge: Generate — Generates SQL migrations from schema
Schema Forge: Diff — Shows schema differences
Schema Forge: Plan — Shows migration operations in human-readable plan format (+ create, ~ modify, - delete)
Schema Forge: Preview — Runs migration preview (alias flow for plan preview)
Schema Forge: Diff Preview — Opens a panel with SQL diff preview
Schema Forge: Visual Diff — Opens a structured view of schema changes (operations and safety findings) with links to SQL preview
Schema Forge: Preview SQL — Previews SQL from schema differences
Status bar: Click the Schema Forge status bar item to open a menu (Show Migration Plan, Run Migration Preview, Run Diff Preview, Open Visual Diff, Generate). The status bar shows pending / drift / clean and briefly "checking..." after save while diff runs.
Phase 2: Editor Features
Syntax Highlighting & Snippets
The extension includes TextMate highlighting for Schema Forge DSL constructs, including:
- Table declarations and column definitions
- Types, modifiers, function defaults, and literals
- Multiline RLS policy blocks such as
policy, for, to, using, and with check
Available snippets include:
table — Creates a table scaffold with a UUID primary key
uuidpk — Inserts a UUID primary key column
timestamps — Adds created_at and updated_at
policy — Creates a multiline RLS policy block
Example policy snippet expansion:
policy "policy_name" on table_name
for select
using table.id = id
Diagnostics
Errors and warnings appear in VS Code's Problems panel (Ctrl+Shift+M / Cmd+Shift+M). Rules run on file save (immediate) and on change (debounced 250ms).
| Code |
Description |
Severity |
SF_SYNTAX_ERROR |
Parsing error in schema file |
Error |
SF_NO_COLUMNS |
Table has no columns defined |
Error |
SF_NO_PK |
Table is missing a primary key |
Error |
SF_MULTIPLE_PK |
Table has multiple primary key columns |
Warning |
SF_DUPLICATE_COLUMN |
Duplicate column names in table |
Error |
SF_UNKNOWN_TYPE |
Unsupported or unknown column type |
Error |
SF_INVALID_DEFAULT_NOW |
default now() used on non-timestamptz column |
Warning |
Problems panel showing real-time diagnostics with all 7 rule codes
Diagnostic Examples
SF_SYNTAX_ERROR — Parsing error in schema file
Table definition not properly closed
SF_NO_COLUMNS — Table has no columns defined
Table with no column definitions
SF_NO_PK — Table is missing a primary key
Table without a primary key column
SF_MULTIPLE_PK — Table has multiple primary key columns
Table with more than one primary key
SF_DUPLICATE_COLUMN — Duplicate column names in table
Same column name defined twice
SF_UNKNOWN_TYPE — Unsupported or unknown column type
Using an unsupported data type
SF_INVALID_DEFAULT_NOW — default now() used on non-timestamptz column
Using default now() on wrong column type
Valid Schema — No errors
Properly structured schema with all validations passing
Hover Docs
Hover over DSL keywords to see in-editor documentation:
- table — Declares a database table
- uuid — 128-bit unique identifier type (pairs with
gen_random_uuid())
- text — Unbounded variable-length string
- varchar — Variable-length string with optional limit (e.g.,
varchar(255))
- timestamptz — Timestamp with timezone (use with
default now())
- pk — Primary key modifier
- unique — Unique constraint modifier
- default — Default value modifier (e.g.,
default now(), default true)
Quick Fixes
When applicable diagnostics are present, a lightbulb icon appears. Press Ctrl+. (Cmd+. on macOS) to open Quick Fixes:
Add primary key column**
- Triggered by:
SF_NO_PK
- Action: Inserts
{columnName} uuid pk at the table start
- Smart naming: Auto-selects available name from
id → pk_id → {tableName}_id → id_pk
- Preserves indentation and existing structure
Convert to 'id uuid pk'
- Triggered by:
SF_NO_PK on a column definition
- Action: Rewrites selected column to
id uuid pk format
- Safety: Prevents conversion if table already has an
id column
- Removes conflicting
pk modifiers on rewrite
Quick Fix lightbulb converts a column to 'id uuid pk'
Release line support (RLS)
This extension supports VS Code 1.70.0 and newer (^1.70.0). It is tested against the current VS Code release line. Older VS Code versions are not supported.
Compatibility & Limitations
Semantic Validation: Rules are MVP-level and provider-agnostic (compatible with Postgres, Supabase, and other Postgres-based systems).
Language Recognition: Editor intelligence requires:
- File extension:
.sf
- Language mode: "Schema Forge" (auto-detected, or manually set)
Supported Column Types: uuid, varchar, varchar(n), text, int, bigint, numeric(m,n), boolean, timestamptz, date
Phase 1 vs Phase 2: CLI commands (Init, Generate, Diff) execute the Schema Forge CLI. Editor features (Diagnostics, Hover, Quick Fixes) use the core library without spawning processes.
Configuration
Settings (coming soon) — Phase 3 will introduce configuration for diagnostic severity overrides and feature toggles.
Troubleshooting
Q: Diagnostics are not showing
A: Ensure the file ends with .sf and the language mode is "Schema Forge". Check View → Output and select "Schema Forge" from the dropdown to see detailed logs.
Q: Quick Fix is not offered
A: Quick Fixes appear only when a matching diagnostic is present. Check the Problems panel (Ctrl+Shift+M) for applicable errors (e.g., SF_NO_PK).
Q: "Core parse fails" or syntax error
A: Check the Problems panel for SF_SYNTAX_ERROR diagnostic. Review your schema syntax against the Schema Forge documentation.
Language Support
The extension contributes:
- Language ID:
schema-forge
- File extension:
.sf
- Scope name:
source.schemaforge
Installation
Marketplace (recommended)
Install directly from the Visual Studio Marketplace.
Install from Open VSX (Cursor/VSCodium compatible).
Build from source
git clone https://github.com/xubylele/schema-forge-vscode.git
cd schema-forge-vscode
npm install
npm run build
Then press F5 in VS Code to launch an Extension Development Host.
Install as VSIX
npm run package:vsix
In VS Code, run Extensions: Install from VSIX... and choose the generated file.
Quick Start
- Open a workspace.
- Create or open a
.sf file.
- Run
Schema Forge: Init if your schemaforge/ folder does not exist.
- Use
Schema Forge: Plan, Schema Forge: Preview, Schema Forge: Generate, Schema Forge: Diff, Schema Forge: Diff Preview, or Schema Forge: Preview SQL from the Command Palette.
Development
npm install
npm run watch
Useful scripts:
npm run build
npm run lint
npm test
Contributing
Contributions are welcome. Please follow CONTRIBUTING.md.
All contributor pull requests must target the develop branch.
Release Channels
pre-release: publishes prerelease versions (X.Y.Z-next.N)
master: publishes stable versions (X.Y.Z)
License
MIT