Kadak

Migrations

Create and run SQL migrations with built-in tracking.

Migrations

Problem: running SQL files manually causes drift across environments.

Solution: use createMigration() and runMigrations().

Create a migration file

import { createMigration } from '@shyk/kadak-orm'

const filePath = await createMigration('create_users_table')
console.log(filePath)

KadakORM creates a timestamped SQL file in ./migrations.

Apply migrations

import { runMigrations } from '@shyk/kadak-orm'

const result = await runMigrations({
  url: 'postgres://postgres:postgres@localhost:5432/kadak_demo',
  dir: './migrations',
  tableName: 'kadak_migrations',
})

console.log('applied', result.applied)
console.log('skipped', result.skipped)

Important: KadakORM executes .sql files in sorted filename order.

On this page