# Substreams SQL

> Use this when building SQL database sinks from Substreams: PostgreSQL vs ClickHouse, Database Changes vs From-proto, primary keys, delta updates, and schema evolution.

- Skill: `shixuuu/substreams-sql` (Agent Skill)
- Install (CLI): `npx get-skill add shixuuu/substreams-sql`
- Raw SKILL.md: https://api.skillmd.com/api/skills/shixuuu/substreams-sql/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- Author: Shixuuu (https://skillmd.com/u/shixuuu)
- Updated: 2026-11-24
- Page: https://skillmd.com/skills/shixuuu/substreams-sql

---


Build the Substreams module that feeds a SQL sink (substreams sink postgres / substreams sink clickhouse) — PostgreSQL or ClickHouse.

Scope: module design, proto/schema shape, and mapping mode. For running a sink yourself use substreams-sink-deploy-local; for StreamingFast-hosted sinks use substreams-hosted-sink.

Pre-flight: do not write manifests, schemas, or Rust until sink type and mutability are answered. One question per turn, including Other / custom. Mutable balances / current-state entities → PostgreSQL + Database Changes. ClickHouse and from-proto are insert-only.

When this skill applies, immediately read the upstream SKILL.md and references at https://github.com/streamingfast/substreams-skills (v1.6.0), pack `substreams-sql` (clickhouse-patterns.md, database-changes.md). Follow those files.

