agentleFS
aiqadamaiqadam/qadam-flow/.agents/skills/db-migration/SKILL.md

db-migration

Skill5 starsChanged 38 days agoMITView on GitHub

Creates TypeORM database migrations for the Qadam Flow server. Use when the user asks to add a column, create a table, add an index, or make any schema change to the database.

26 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use api-endpoint, write-tests and 4 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • tadoEngSkill

    api-endpoint

    Add or change a backend API endpoint on this product, keeping Pydantic as the single contract authority and regenerating the TypeScript client. Use when asked to add an endpoint, expose data to the frontend, change a request or response shape, or wire a new backend capability into a page.

    Also in 4 projects that use this

  • SentrySkill

    write-tests

    Write tests following project conventions. Use when adding new tests or modifying existing ones.

    Also in 3 projects that use this

  • Microsoft AzureSkill

    git-workflow

    Squad branching model: dev-first workflow with insiders preview channel

    Also in 3 projects that use this

  • Microsoft AzureSkill

    verify

    End-to-end app testing pipeline for browser-based web apps on cloud browsers via Azure Playwright Workspaces: verify the live app, author tests for working flows, heal failing tests, then re-run with video and produce one consolidated report. Three phases (app verification, test authoring, test healing) plus a scoped final sanity run; each phase emits a sub-report. Use when asked to "verify my app", "make sure my app works and has good test coverage", "do a full QA pass", "add tests where I'm missing coverage", "fix failing tests and add new ones", "smoke test before deploy", "QA my deployment", or any combined verify-and-test ask. Requires Azure CLI (`az login`) and a Playwright Workspace resource ID — bootstraps configs on first invocation. Browser-based web apps with Playwright only — not for unit/API tests, native mobile/desktop, load/perf, or full accessibility audits.

    Also in 4 projects that use this

  • AnthropicSkill

    debug

    Structured debugging session — reproduce, isolate, diagnose, and fix. Trigger with an error message or stack trace, "this works in staging but not prod", "something broke after the deploy", or when behavior diverges from expected and the cause isn't obvious.

    Also in 3 projects that use this

  • MicrosoftSkill

    release

    Use ONLY when the user explicitly asks to cut/publish a Huabu desktop release or tag a version. Performs an outward action — bumps the version in apps/desktop/package.json, commits + annotated-tags vX.Y.Z, and pushes the branch + tag. That tag push auto-builds the macOS/Windows installers and publishes a GitHub Release. Provides `status`, `bump`, `tag-push`, and a one-command `run` (bump → tag-push).

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 22 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create TypeORM database migrations for schema changes in the Qadam Flow server API.

    line 8
  2. Very specific:

    Update the TypeORM entity file in packages/server/api/src/app/ to reflect the new schema.

    line 24
  3. Very specific:

    Add breaking = false (or true if destructive)

    line 50
  4. Very specific:

    Add release = '<version>' — the upcoming release, node tools/ci/compute-main-version.mjs --next

    line 51
  5. Very specific:

    Verify down() correctly reverses up()

    line 52
  6. Distinctive:

    After the migration is generated and registered, update any TypeScript types, service files, or other code that references the changed …

    line 109
  7. Distinctive:

    Always try to create non-breaking migrations if possible to allow safe rollbacks

    line 113

“Common” is measured: kept by at least 6 in 10 of the 22 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Qadam Flow DB Migration

Create TypeORM database migrations for schema changes in the Qadam Flow server API.

Workflow

Step 1: DETERMINE THE CHANGE

Before generating, identify:

  • Which table(s) are affected
  • What SQL is needed (ADD COLUMN, CREATE TABLE, CREATE INDEX, etc.)
  • Whether the migration is breaking (drops columns/tables, transforms data irreversibly — cannot be rolled back safely)
  • The release the migration will ship in: node tools/ci/compute-main-version.mjs --next. Not the root package.json — under ADR-0001 that holds the last release, which the migration is not part of (#798)

Step 2: UPDATE THE ENTITY

Update the TypeORM entity file in packages/server/api/src/app/ to reflect the new schema. This ensures the CLI generation command can diff against the current state.

Array columns always use this pattern:

columnName: {
    type: String,
    array: true,
    nullable: false,
}

Step 3: GENERATE THE MIGRATION USING THE CLI

Run from packages/server/api/:

npm run db-migration -- src/app/database/migration/postgres/MigrationName

This diffs the current entity state against the database and generates the migration file with correct SQL and timestamp.

Step 4: PATCH THE GENERATED FILE

The CLI generates a file using MigrationInterface. You must patch it to use the project's Migration interface and add required fields:

  1. Replace import { MigrationInterface, QueryRunner } from "typeorm" with import { QueryRunner } from 'typeorm' and add import { Migration } from '../../migration'
  2. Replace implements MigrationInterface with implements Migration
  3. Add breaking = false (or true if destructive)
  4. Add release = '<version>' — the upcoming release, node tools/ci/compute-main-version.mjs --next
  5. Verify down() correctly reverses up()

Example result:

import { QueryRunner } from 'typeorm'
import { Migration } from '../../migration'

export class AddMyColumn1234567890 implements Migration {
    name = 'AddMyColumn1234567890'
    breaking = false 
    release = '0.78.0'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE "project" ADD COLUMN "description" text`)
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE "project" DROP COLUMN "description"`)
    }
}

Required fields:

  • name = '<ExportedClassName>' — the CLI sets this; do not blank it out
  • breaking = false — set to true only if rolling back is destructive
  • release = '<version>' — the upcoming release (node tools/ci/compute-main-version.mjs --next; never the root package.json's last release, or rolling back to that release would keep the migration)
  • down() — must reverse up() (required)

The Migration type marks breaking/release optional, but _verify.yml's "Check new migration metadata" step (part of the required Lint + Unit Tests check, not a separate context of its own) runs tools/scripts/check-migration-rollback.ts (npm run check-migration-metadata) on every PR (#445): a new migration missing name, breaking, an invalid/missing release, or missing down() fails the build and names the field. down() missing is actually caught earlier still, at compile time — typeorm's MigrationInterface.down is non-optional. name matters beyond the gate too: rollback-migrations.ts keys manifest-based rollback on it, so a blank or mismatched one silently drops the migration from that path instead of failing loudly — the gate also checks it matches the exported class name. Set all four anyway; do not rely on the gate to catch it.

Step 5: REGISTER THE MIGRATION

Open packages/server/api/src/app/database/postgres-connection.ts and add the new migration class to the getMigrations() array (at the end, in chronological order):

import { AddMyColumn1234567890 } from './migration/postgres/1234567890-AddMyColumn'

// Inside getMigrations():
return [
    // ... existing migrations ...
    AddMyColumn1234567890,
]

Step 6: UPDATE TYPES AND SERVICE CODE

After the migration is generated and registered, update any TypeScript types, service files, or other code that references the changed columns to stay in sync with the new schema.

Note:

Always try to create non-breaking migrations if possible to allow safe rollbacks

Zero errors required before the task is complete.


Using CONCURRENTLY

Qadam Flow runs against real PostgreSQL only (PGLite support was removed). When creating or dropping indexes with CONCURRENTLY, set transaction = false on the migration — PostgreSQL requires it, since CONCURRENTLY cannot run inside a transaction:

import { QueryRunner } from 'typeorm'
import { Migration } from '../../migration'

export class AddMyIndex1234567890 implements Migration {
    name = 'AddMyIndex1234567890'
    breaking = false
    release = '0.78.0'
    transaction = false  // Required when using CONCURRENTLY

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE INDEX CONCURRENTLY "idx_name" ON "table" ("column")`)
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`DROP INDEX CONCURRENTLY "idx_name"`)
    }
}

Quick Reference

FieldValue
Migration filespackages/server/api/src/app/database/migration/postgres/
Registrationpackages/server/api/src/app/database/postgres-connection.ts
Migration importimport { Migration } from '../../migration'
Generate commandnpm run db-migration -- src/app/database/migration/postgres/MigrationName (run from packages/server/api/)

Critical Reminders

  1. Always generate via CLI — never write migration SQL by hand; use npm run db-migration to generate from the entity diff
  2. Never use MigrationInterface — always patch the generated file to use Migration from ../../migration
  3. name, breaking, release, and down() are mandatory — set them explicitly; a required CI check (npm run check-migration-metadata) rejects a new migration that omits one
  4. Register in postgres-connection.ts — migration won't run without this
  5. CONCURRENTLY — always set transaction = false when using it

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.