timescale avatar

Migrate Postgres Tables To Hypertables

Takes a PostgreSQL table and converts it to a TimescaleDB hypertable with proper chunk intervals, compression settings, and primary key handling. The skill walks through partition column selection (usually a timestamp), calculates optimal chunk sizes based on your RAM and index sizes, and importantly asks permission before modifying any primary keys that don't include the partition column. For small tables it does in-place conversion, for larger ones it sets up blue-green migration. The compression configuration part is solid, helping you pick segment_by columns based on cardinality analysis. Use this after you've identified candidates, ideally with the companion find-hypertable-candidates skill first.

skills.sh installs
368
GitHub stars
1.9K
last updated
Aug 21, 2026

Install

$ npx -y skills add timescale/pg-aiguide --skill migrate-postgres-tables-to-hypertables --agent claude-code

Installs into .claude/skills of the current project.

Files

PostgreSQL to TimescaleDB Hypertable Migration

Migrate identified PostgreSQL tables to TimescaleDB hypertables with optimal configuration, migration planning and validation.

Prerequisites: Tables already identified as hypertable candidates (use companion "find-hypertable-candidates" skill if needed).

Step 1: Optimal Configuration

Partition Column Selection

-- Find potential partition columns
SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_name = 'your_table_name'
  AND data_type IN ('timestamp', 'timestamptz', 'bigint', 'integer', 'date')
ORDER BY ordinal_position;

Requirements: Time-based (TIMESTAMP/TIMESTAMPTZ/DATE) or sequential integer (INT/BIGINT)

Should represent when the event actually occurred or sequential ordering.

Common choices:

  • timestamp, created_at, event_time - when event occurred
  • id, sequence_number - auto-increment (for sequential data without timestamps)
  • ingested_at - less ideal, only if primary query dimension
  • updated_at - AVOID (records updated out of order, breaks chunk distribution) unless primary query dimension

Sponsors

Details

Repository
github.com/timescale/pg-aiguide
Categories
Backend & APIs, Debugging, Productivity & Planning, Marketing & SEO, Databases
License
Apache-2.0
First seen
Jun 3, 2026

More from timescale/pg-aiguide

All 8
1zzci avatarpma-crzzci/skillsCode review: stack-aware review for local diffs, pull requests, and repository-wide audits. Routes review across shared policy plus language packs for TypeScrip368skills.sh installs
2davila7 avatarfigma-implement-designdavila7/claude-code-templatesTranslate Figma nodes into production-ready code with 1:1 visual fidelity using the Figma MCP workflow (design context, screenshots, assets, and project-convent367skills.sh installs
3huggingface avatarhugging-face-datasetshuggingface/skillsCreate and manage datasets on Hugging Face Hub. Supports initializing repos, defining configs/system prompts, streaming row updates, and SQL-based dataset query367skills.sh installs
4cloudwego avatareino-agentcloudwego/eino-extEino ADK agent construction, middleware, and runner. Use when a user needs to build an AI Agent, configure ChatModelAgent with ReAct pattern, use middleware (fi366skills.sh installs
5zzci avatarpma-gozzci/skillsGo implementation guide for PMA-managed service and CLI projects. Covers project layout (cmd/internal), strict linting with golangci-lint v2, database access (s366skills.sh installs
6davila7 avatarnotebooklmdavila7/claude-code-templatesUse this skill to query your Google NotebookLM notebooks directly from Claude Code for source-grounded, citation-backed answers from Gemini. Browser automation,365skills.sh installs