Database Support
- PostgreSQL
- PGlite
Editions
- Enterprise & Cloud Edition (Must use PostgreSQL)
- Community Edition (Can use PostgreSQL or PGlite)
How To Generate
1
Setup AP_DB_TYPE
Set the
AP_DB_TYPE environment variable to POSTGRES after making sure have latest state by running Activepieces first.2
Generate Migration
Run the migration generation command:Replace
<MIGRATION_NAME> with a descriptive name for your migration.3
Update Migration File
The command will generate a new migration file in CI will fail if
packages/server/api/src/app/database/migration/postgres/.The generated file uses MigrationInterface — you need to update it:- Change
implements MigrationInterfacetoimplements Migration - Update the import from
typeormto importMigrationfrom../../migration - Add
breaking = false(ortrueif the migration drops columns/tables or transforms data irreversibly) - Add
release = '<version>'matching the upcoming release version (checkpackage.jsonin the repo root) - Implement the
down()method with queries that reverse theup()changes (unlessbreaking = true) - Register it in
postgres-connection.ts
breaking, release, or down() are missing on new migrations.PGlite Compatibility
While PGlite is mostly PostgreSQL-compatible, some features are not supported. When using features likeCONCURRENTLY for index operations, you need to conditionally handle PGlite:
Cleaning Up After a Background Migration
A background migration often leaves temporary code behind: a fallback read from the old shape, a dual write, a legacy column or index, special handling until the backfill finishes. Plan its removal when the migration ships, not later.1
Open a Linear ticket when the migration merges
Create a ticket assigned to the migration’s owner (the author of the PR that adds it). Name the migration and the target releases in the title, for example “Remove the
piece_metadata.i18n fallback after BackfillPieceTranslation (code 0.97.0, column 0.98.0)”.In the body, list every piece of code and schema that becomes removable (symbol and file), link the migration PR, and copy in the two steps below. Link the ticket from the migration PR’s description.2
Remove the code in release N+4 or later
N is the minor version in the migration’s
release field, so release = '0.93.0' means the code goes in 0.97.0 or later. We support the latest five releases, so once N+4 is the newest, every supported release (N to N+4) already ships the backfill. N+3 is too early, because N-1 is still supported then.Ship code only. Remove the fallbacks and dual writes, take the field off the entity, and add a blocking migration whose up() only calls migrationHelpers.assertBackgroundMigrationComplete(...). That guard makes an older install that skips releases run the backfill at boot before it serves traffic.3
Drop the schema in release N+5 or later
Drop the column, table or index in release N+5 or later, and always at least one release after the code removal, in a blocking migration guarded the same way, with
breaking = true. For release = '0.93.0' that is 0.98.0 or later. A dropped column is a technical breaking change: it needs the ⛓️💥 breaking-change label and an entry in docs/install/reference/breaking-changes-unreleased.mdx.