Tooluck logoTooluck
SKILL.md

migrate-postgres-tables-to-hypertables

Agent skill fromtimescale/pg-aiguide

Use this skill to migrate identified PostgreSQL tables to Timescale/TimescaleDB hypertables with optimal configuration and validation. **Trigger when user asks to:** - Migrate or convert PostgreSQL tables to hypertables - Execute hypertable migration with minimal downtime - Plan blue-green migration for large tables - Validate hypertable migration success - Configure compression after migration **Prerequisites:** Tables already identified as candidates (use find-hypertable-candidates first if needed) **Keywords:** migrate to hypertable, convert table, Timescale, TimescaleDB, blue-green migration, in-place conversion, create_hypertable, migration validation, compression setup Step-by-step migration planning including: partition column selection, chunk interval calculation, PK/constraint handling, migration execution (in-place vs blue-green), and performance validation queries.

How to install migrate-postgres-tables-to-hypertables

install migrate-postgres-tables-to-hypertables
# install the pg-aiguide pack with the skills CLI
npx skills add timescale/pg-aiguide

# or add only this skill to Claude Code: copy the folder

skills/migrate-postgres-tables-to-hypertables/

# into

~/.claude/skills/migrate-postgres-tables-to-hypertables/ (all projects)

.claude/skills/migrate-postgres-tables-to-hypertables/ (one project)

skills/migrate-postgres-tables-to-hypertables/SKILL.md

Apache-2.0Full file
1# PostgreSQL to TimescaleDB Hypertable Migration
2
3Migrate identified PostgreSQL tables to TimescaleDB hypertables with optimal configuration, migration planning and validation.
4
5**Prerequisites**: Tables already identified as hypertable candidates (use companion "find-hypertable-candidates" skill if needed).
6
7## Step 1: Optimal Configuration
8
9### Partition Column Selection
10
11```sql
12-- Find potential partition columns
13SELECT column_name, data_type, is_nullable
14FROM information_schema.columns
15WHERE table_name = 'your_table_name'
16 AND data_type IN ('timestamp', 'timestamptz', 'bigint', 'integer', 'date')
17ORDER BY ordinal_position;
18```
19
20**Requirements:** Time-based (TIMESTAMP/TIMESTAMPTZ/DATE) or sequential integer (INT/BIGINT)
21
22Should represent when the event actually occurred or sequential ordering.
23
24**Common choices:**
25
26- `timestamp`, `created_at`, `event_time` - when event occurred
27- `id`, `sequence_number` - auto-increment (for sequential data without timestamps)
28- `ingested_at` - less ideal, only if primary query dimension
29- `updated_at` - AVOID (records updated out of order, breaks chunk distribution) unless primary query dimension
30
31#### Special Case: table with BOTH ID AND Timestamp
32
33When table has sequential ID (PK) AND timestamp that correlate:
34
35```sql
36-- Partition by ID, enable minmax sparse indexes on timestamp
37SELECT create_hypertable('orders', 'id', chunk_time_interval => 1000000);
38ALTER TABLE orders SET (
39 timescaledb.sparse_index = 'minmax(created_at),...'
40);
41…

Excerpt shown under the repository's Apache-2.0 license.

More skills in pg-aiguide

Keep exploring

Similar skill repositories

thedotmack /

claude-mem
116k

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

CCCXGHGM+135 skills

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates