smithery/Nikola-Milovic

db-workflow

Database workflow with Postgres, Kysely, and Atlas migrations.

Installation

$ npx skills add smithery/Nikola-Milovic --skill db-workflow

Summary

  • Database workflow with Postgres, Kysely, and Atlas migrations.
  • Use when modifying database schema, creating migrations, generating TypeScript types, or troubleshooting database issues.
  • Triggers on "schema change", "migration", "db-migrate", "kysely", "atlas", or when editing db/schema.sql.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/Nikola-Milovic.

npx skills add smithery/Nikola-Milovic

Browse all from smithery/Nikola-Milovic

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,813 B
  • docs SUMMARY.md 309 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

Database Workflow

Source of truth: db/schema.sql is the canonical schema.

Quick Commands

Command Purpose
just db-migrate Apply schema directly (fast iteration)
just db-migration-new <name> Create versioned migration
just db-migration-apply Apply versioned migrations
just db-migration-status Check migration status
just db-schema Generate TypeScript types

Workflow Decision Tree

Schema change needed?
├─ Early development / experimenting
│  └─ Edit db/schema.sql → just db-migrate → just db-schema
│
└─ Production / reviewable history needed
   └─ Edit db/schema.sql → just db-migration-new <name> → just db-migration-apply → just db-schema

Local Dev Setup

# 1. Start Postgres
docker compose up -d  # or: just setup

# 2. Apply schema
just db-migrate

# 3. Generate TypeScript types (after schema changes)
just db-schema

Schema Changes Checklist

  1. Edit db/schema.sql
  2. Apply locally: just db-migrate
  3. Generate types: just db-schema
  4. Update any affected services/routers
  5. Run tests: pnpm test

Versioned Migrations (Atlas)

Even with versioned migrations, db/schema.sql stays the source of truth. Atlas uses it to infer changes.

# Create migration from schema diff
just db-migration-new add_user_roles

# Apply migrations
just db-migration-apply

# Check status
just db-migration-status

Conventions

  • Use uuid primary keys
  • Use createdat / updatedat timestamps
  • Enforce tenancy at service layer (e.g., todos.user_id)
  • Columns mapped to camelCase in TypeScript via Kysely plugin

Runtime DB Access

// packages/backend/core/src/db.ts
import { connectDB, getDB } from "@yourcompany/backend-core/db";

// At app startup (once)
await connectDB({ connectionString: config.DATABASE_URL });

// Anywhere after initialization
const db = getDB();
const users = await db.selectFrom("user").selectAll().execute();

Why Kysely (vs Drizzle/Prisma)

  • Typed query builder without ORM "model" layer
  • Works with SQL-first workflow (db/schema.sql) + codegen
  • Easy to pass db dependency for testing

Gotchas

  • Tests apply db/schema.sql into testcontainers Postgres
  • After schema changes:

- Update db/schema.sql - Re-apply locally (just db-migrate) - Re-generate TS types (just db-schema)

  • Generated types: packages/backend/core/src/schema.ts