# Migrate postgres tables to hypertables

> Migrate postgres tables to hypertables is an open-source agent skill for databases. Guides an agent through converting PostgreSQL tables into TimescaleDB hypertables safely. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/timescale/pg-aiguide/tree/main/skills/migrate-postgres-tables-to-hypertables
- **Repository:** https://github.com/timescale/pg-aiguide
- **GitHub stars:** 1,892
- **License:** Apache-2.0
- **Skill name:** migrate-postgres-tables-to-hypertables
- **Collection:** https://github.com/timescale/pg-aiguide
- **Categories:** [databases](https://ai-powered.com/categories/databases)
- **Listing updated:** 2026-12-04

## About

This skill walks an agent through planning and running the conversion of existing PostgreSQL tables into TimescaleDB hypertables. It covers choosing a partition column, sizing chunk intervals from index size against available memory, and checking primary key and unique constraints so they include the partition column. It also reviews foreign keys, since hypertable-to-hypertable references are not supported, and sets up columnstore compression with segment and order keys.

The skill offers two migration paths: an in-place conversion for smaller tables and a blue-green approach that copies data in batches and swaps tables during a maintenance window for large ones. Before changing constraints or dropping indexes, the agent is told to ask for the user's permission. After migration, it provides queries to check chunk layout, compression ratios and query plans, and it lists signs that the migration should be investigated.

The skill expects a PostgreSQL 15+ database with TimescaleDB available and SQL access to run the queries. It is written as SQL for psql-style execution and does not include bundled scripts.

## When your agent uses it

> 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.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/timescale/pg-aiguide/tree/HEAD/skills/migrate-postgres-tables-to-hypertables)
- [License: Apache-2.0](https://github.com/timescale/pg-aiguide/tree/HEAD/skills/migrate-postgres-tables-to-hypertables)

## Features

- **Partition column selection:** Helps pick a time or sequential integer column that reflects when events occurred.
- **Chunk interval sizing:** Calculates a chunk interval from index size per hour and available memory.
- **Constraint compatibility checks:** Finds primary keys and unique constraints that must be extended to include the partition column.
- **In-place and blue-green paths:** Offers a direct conversion for small tables and a batched table swap for large ones.
- **Compression setup:** Configures segment and order keys, sparse indexes and a columnstore policy.
- **Post-migration validation:** Provides queries for chunk exclusion, compression ratios and query plan comparison.

## Good for

- Convert a large sensor readings table into a hypertable with minimal downtime
- Pick a partition column and chunk interval for an events table
- Check whether a primary key must change before converting a table
- Set up compression on a converted metrics table
- Verify that a hypertable migration improved query performance

## Install

### Claude Code

This skill ships in the `pg` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add timescale/pg-aiguide
/plugin install pg@aiguide
```

Or copy only this skill to `~/.claude/skills/migrate-postgres-tables-to-hypertables`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/migrate-postgres-tables-to-hypertables &&
cp -R "$tmp/skills/migrate-postgres-tables-to-hypertables" ~/.claude/skills/migrate-postgres-tables-to-hypertables &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/migrate-postgres-tables-to-hypertables` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/migrate-postgres-tables-to-hypertables` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/migrate-postgres-tables-to-hypertables &&
cp -R "$tmp/skills/migrate-postgres-tables-to-hypertables" ~/.agents/skills/migrate-postgres-tables-to-hypertables &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/migrate-postgres-tables-to-hypertables` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/migrate-postgres-tables-to-hypertables` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/migrate-postgres-tables-to-hypertables &&
cp -R "$tmp/skills/migrate-postgres-tables-to-hypertables" ~/.cursor/skills/migrate-postgres-tables-to-hypertables &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/migrate-postgres-tables-to-hypertables` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/timescale/pg-aiguide.git --path skills/migrate-postgres-tables-to-hypertables
```

Or copy the folder to `~/.gemini/skills/migrate-postgres-tables-to-hypertables` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/migrate-postgres-tables-to-hypertables`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/migrate-postgres-tables-to-hypertables &&
cp -R "$tmp/skills/migrate-postgres-tables-to-hypertables" ~/.copilot/skills/migrate-postgres-tables-to-hypertables &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/migrate-postgres-tables-to-hypertables` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/timescale/pg-aiguide.git
```

Then copy `pg-aiguide/skills/migrate-postgres-tables-to-hypertables` into your agent's skills folder as `migrate-postgres-tables-to-hypertables`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What does the skill need before Migrate postgres tables to hypertables runs?

Tables already identified as hypertable candidates, PostgreSQL 15+ with TimescaleDB, and the find-hypertable-candidates skill if candidates are not yet known.

### Does Migrate postgres tables to hypertables change the database automatically?

It provides SQL for migration steps, but it asks the user for permission before modifying primary keys, unique constraints or dropping indexes or foreign keys.

### When should blue-green migration be used?

The skill suggests in-place conversion for tables under 1GB and blue-green migration for larger tables, with batched copying and a maintenance-window swap.

### Which default chunk interval does Migrate postgres tables to hypertables recommend?

It says to keep the 7-day default if unsure, and to calculate a different interval from index size when there is data to measure.

### How do I install Migrate postgres tables to hypertables in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/migrate-postgres-tables-to-hypertables to use it in all your projects, or to .claude/skills/migrate-postgres-tables-to-hypertables in one project. Or install the pg plugin, which includes it: /plugin marketplace add timescale/pg-aiguide, then /plugin install pg@aiguide.

### Does Migrate postgres tables to hypertables run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Migrate postgres tables to hypertables?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Migrate postgres tables to hypertables?

The closest alternatives to Migrate postgres tables to hypertables are Find hypertable candidates, Setup timescaledb hypertables, Postgres, Design postgres tables and Postgres database migration.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Find hypertable candidates](https://ai-powered.com/skills/find-hypertable-candidates): Find hypertable candidates is an open-source agent skill for databases.
- [Setup timescaledb hypertables](https://ai-powered.com/skills/setup-timescaledb-hypertables): Setup timescaledb hypertables is an open-source agent skill for databases.
- [Postgres](https://ai-powered.com/skills/postgres-timescale): Postgres is an open-source agent skill for databases.
- [Design postgres tables](https://ai-powered.com/skills/design-postgres-tables): Design postgres tables is an open-source agent skill for databases.
- [Postgres database migration](https://ai-powered.com/skills/postgres-database-migration): Postgres database migration is an open-source agent skill for databases.
- [Database migrations](https://ai-powered.com/skills/database-migrations): Database migrations is an open-source agent skill for databases.
- [Database migrations](https://ai-powered.com/skills/database-migrations-nabwinsaud): Database migrations is an open-source agent skill for databases.
- [PostgreSQL optimization](https://ai-powered.com/skills/postgresql-optimization): PostgreSQL optimization is an open-source agent skill for databases.

---
Source: https://ai-powered.com/skills/migrate-postgres-tables-to-hypertables
