원클릭으로
db-migration
Creates TypeORM database migrations for the Activepieces server. Use when the user asks to add a column, create a table, add an index, or make any schema change to the database.
메뉴
Creates TypeORM database migrations for the Activepieces server. Use when the user asks to add a column, create a table, add an index, or make any schema change to the database.
Builds Activepieces pieces (integrations) with actions and triggers. Use when the user asks to create a new piece, add actions to a piece, add triggers to a piece, or build an integration for a third-party app. Also use when the user mentions Activepieces pieces, connectors, or integration development.
Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
Design system for Activepieces (open-source AI automation platform, "open source replacement for Zapier"). Use whenever designing, mocking, or building UI for Activepieces — the web app (flow builder, runs, connections, dashboard), docs, or marketing surfaces. Provides brand purple `#8142E3`, Inter type ramp with `sm` (14px) as body default, Tailwind neutrals, Lucide icons, Shadcn/Radix primitive conventions, the signature dotted-canvas builder background, and a recreated web UI kit.
Use when adding a new API endpoint, route, or HTTP handler. ALWAYS use for new Fastify controller endpoints.
Use when creating a new database table, entity, or data model. ALWAYS use for any new TypeORM EntitySchema creation.
Use when the user asks to add a feature, implement functionality, or build something spanning database, API, and frontend. ALWAYS use for multi-layer feature work.
| name | db-migration |
| description | Creates TypeORM database migrations for the Activepieces server. Use when the user asks to add a column, create a table, add an index, or make any schema change to the database. |
Create TypeORM database migrations for schema changes in the Activepieces server API.
Before generating, identify:
ADD COLUMN, CREATE TABLE, CREATE INDEX, etc.)package.json → version)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,
}
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.
The CLI generates a file using MigrationInterface. You must patch it to use the project's Migration interface and add required fields:
import { MigrationInterface, QueryRunner } from "typeorm" with import { QueryRunner } from 'typeorm' and add import { Migration } from '../../migration'implements MigrationInterface with implements Migrationbreaking = false (or true if destructive)release = '<version>' matching the upcoming release version from root package.jsondown() 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:
breaking = false — set to true only if rolling back is destructiverelease = '<version>' — the upcoming release version from root package.jsondown() — must reverse up() (required)CI fails if any of these are missing.
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,
]
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.
Always try to create non-breaking migrations if possible to allow safe rollbacks
Zero errors required before the task is complete.
PGlite does not support CONCURRENTLY (it is a single-connection embedded database). When creating or dropping indexes with CONCURRENTLY, add a PGlite check:
import { QueryRunner } from 'typeorm'
import { Migration } from '../../migration'
import { system } from '../../../helper/system/system'
import { AppSystemProp } from '../../../helper/system/system-props'
import { DatabaseType } from '../../database-type'
const isPGlite = system.get(AppSystemProp.DB_TYPE) === DatabaseType.PGLITE
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> {
if (isPGlite) {
await queryRunner.query(`CREATE INDEX "idx_name" ON "table" ("column")`)
} else {
await queryRunner.query(`CREATE INDEX CONCURRENTLY "idx_name" ON "table" ("column")`)
}
}
public async down(queryRunner: QueryRunner): Promise<void> {
if (isPGlite) {
await queryRunner.query(`DROP INDEX "idx_name"`)
} else {
await queryRunner.query(`DROP INDEX CONCURRENTLY "idx_name"`)
}
}
}
Set transaction = false whenever using CONCURRENTLY — PostgreSQL requires it.
| Field | Value |
|---|---|
| Migration files | packages/server/api/src/app/database/migration/postgres/ |
| Registration | packages/server/api/src/app/database/postgres-connection.ts |
Migration import | import { Migration } from '../../migration' |
| Generate command | npm run db-migration -- src/app/database/migration/postgres/MigrationName (run from packages/server/api/) |
npm run db-migration to generate from the entity diffMigrationInterface — always patch the generated file to use Migration from ../../migrationbreaking, release, and down() are mandatory — CI will reject the migration without thempostgres-connection.ts — migration won't run without thisisPGlite and set transaction = false