console/packages/migrations
2026-03-16 10:22:42 +01:00
..
src feat: add app_deployment_documents.target_id column (#7832) 2026-03-16 10:22:42 +01:00
test Store schema proposal changes on a separate column in the schema chec… (#7531) 2026-01-22 14:37:11 -08:00
tools fix: load environment variables (#6414) 2025-01-24 10:33:13 +00:00
.env.template feat(migrations): add configurable data retention TTL for self-hosted instances (#7303) 2025-12-09 23:16:52 +02:00
.gitignore add prettier-plugin-sql (#1555) 2023-03-07 11:34:59 +02:00
package.json chore: bump jsdiff (#7517) 2026-01-20 14:00:43 +01:00
README.md use custom migrator and avoid running ts-node and typescript in the d… (#2607) 2023-07-17 13:14:50 +02:00
tsconfig.json distributed tracing (#4219) 2024-04-07 11:57:03 +03:00

@hive/migrations

Service for creating, managing and running database migrations.

We are using Slonik Migrator under the hood, to generate, manage, track and run migrations.

Development Workflow

To add new migrations, please follow the instructions below, based on the type of the migration you need to implement.

Please follow these guidelines:

  1. Do not delete previous migration files!
  2. Do not change any existing migration code or file name, once it's merged to main branch!
  3. If you need a change in database or structure, make sure that the down migration does the exact opposite (usually, in the reversed order).
  4. Migrations should not take too long to run - if your migration is doing too many things, please consider to break it to smaller pieces, or rethink your implemenation.
  5. Remember: the database in production always contains more data: a tiny migration on development might take a long time to complete on production environment!

Please refer to the package.json of this package for useful scripts that might make it simpler for you to write migrations.

Adding new Postgres migrations

For postgres migrations, just create a new file (copy a previous migration).

Then, adjust the content and migration name as desired. Make sure you import in src/run-pg-migrations.ts and add it to the list of migrations to run.

ClickHouse Migrations

We aim to avoid ClickHouse data migrations, as they are heavy and complicated to apply.

If you need to apply ClickHouse database structure changes, please try to add and avoid changes to existing objects.

Follow src/clickhouse.ts for more information and the detailed database structure.

Custom Migrations

You are also able to use TypeScript to write and apply migrations.

To create a custom migration, use the following command:

pnpm migration:create --name "do_something.mts" --allow-extension ".mts"

If you need external dependencies at runtime, please make sure to add your dependencies under dependencies in package.json.