Dust Db Migration logo

Dust Db Migration

OrganizationPopular
dust-tt
dust-db-migration

Step-by-step guide for creating and running SQL schema migrations in `front` or `connectors` using the `npm run migration:*` tooling (pg-schema-diff + Umzug). Use when adding or removing columns, tables, or indexes that require a coordinated deploy.

Overview

Publisherdust-tt
Repositorydust
Skill namedust-db-migration
Stars
1.5K
Forks
370
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by dust-tt on GitHub. Read the source before you install it.

Installation

Install the Dust Db Migration AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/dust-tt/dust/tree/main/.claude/skills/dust-db-migration
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dust-tt/dust.git /tmp/dust
mkdir -p .claude/skills
cp -r /tmp/dust/.claude/skills/dust-db-migration .claude/skills/dust-db-migration
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Dust Db Migration in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Dust Db Migration on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Dust Db Migration is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

DB Migrations (front / connectors)

Use this skill whenever a code change requires a schema change. The tooling auto-generates SQL by diffing your local Sequelize models against the running database, so you should update the model/ first, then generate the migration.

The Two Phases

Every migration belongs to one of two phases. Picking the wrong one will either block the deploy or break old code:

PhaseRunExamples
pre-deploybefore new code goes liveADD COLUMN (nullable), CREATE TABLE, CREATE INDEX CONCURRENTLY
post-deployafter new code is liveDROP COLUMN, DROP TABLE, ALTER COLUMN … NOT NULL, tighten constraints

Down migrations are not supported. Rolling back a schema change means a new forward migration (expand/contract pattern).

Prerequisites

These must be available before running any migration command:

  • pg-schema-diff — brew install pg-schema-diff
  • psql — brew install postgresql
  • For front: FRONT_DATABASE_URI env var set
  • For connectors: CONNECTORS_DATABASE_URI env var set (local default: postgres://dev:dev@localhost:5432/dust_connectors)

Step-by-step

1. Update the Sequelize model

Edit the model file in the appropriate location and reflect the desired end state. The generator derives the migration SQL from the model, not from hand-written SQL.

  • front: front/lib/models/
  • connectors: connectors/src/lib/models/

2. Generate the migration SQL

Run from inside front/ or connectors/:

bash
# Pre-deploy (add column, add table, add index)
npm run migration:generate:pre-deploy -- add_column_to_users

# Post-deploy (drop column, tighten constraint)
npm run migration:generate:post-deploy -- drop_legacy_column_from_users

The description words are joined with _. The script will:

  1. Spin up a shadow DB, apply the current branch's models to it
  2. Run pg-schema-diff plan to compare live DB → shadow
  3. Write the SQL to migrations/pre-deploy/<timestamp>_<desc>.sql or migrations/post-deploy/…

If the output says "No schema changes detected", the model and live DB are already in sync — double-check you saved the model file.

3. Review the generated SQL

Open the generated file and verify the SQL looks right. For index additions, confirm CREATE INDEX CONCURRENTLY is used (pg-schema-diff emits this automatically for large tables).

4. Apply locally

bash
# Apply pre-deploy migrations only
npm run migration:apply:pre-deploy

# Apply post-deploy migrations only
npm run migration:apply:post-deploy

# Apply both in sequence
npm run migration:apply

Applied migrations are recorded in the schema_migrations table so they won't re-run.

5. Check status

bash
npm run migration:status

Lists pending (unapplied) migrations for both phases.

File Locations

frontconnectors
Generated migrationsfront/migrations/pre-deploy/, front/migrations/post-deploy/connectors/migrations/pre-deploy/, connectors/migrations/post-deploy/
Migration runnerfront/scripts/migrate.ts (via run-migrate.cjs)connectors/scripts/migrate.ts (via run-migrate.cjs)
Generator scriptfront/scripts/generate-migration.shconnectors/scripts/generate-migration.sh
DB env varFRONT_DATABASE_URICONNECTORS_DATABASE_URI
  • Applied migration ledger: schema_migrations table (columns: name, phase, applied_at)

Key Implementation Details

  • The runner uses Umzug with a custom PhasedSequelizeStorage that namespaces entries by phase (pre-deploy/<filename> vs post-deploy/<filename>), so same-named files in both phases never collide.
  • Migrations are applied via psql -f <file> (not a library client) so that CREATE INDEX CONCURRENTLY and SET SESSION commands work correctly through pgbouncer's transaction-pooling mode.
  • There is no down / rollback support. A unlogMigration call throws by design.

Frequently asked questions

What does the Dust Db Migration AI skill do?

Step-by-step guide for creating and running SQL schema migrations in `front` or `connectors` using the `npm run migration:*` tooling (pg-schema-diff + Umzug). Use when adding or removing columns, tables, or indexes that require a coordinated deploy.

Why use Dust Db Migration on TypingMind?

Because you install it once and use it with any model. Dust Db Migration is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Dust Db Migration in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dust-tt/dust/tree/main/.claude/skills/dust-db-migration. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Dust Db Migration?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Dust Db Migration?

As many as you like. As long as a model supports skills, you can use Dust Db Migration with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Dust Db Migration AI skill free?

Yes. It is published on GitHub by dust-tt under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇