Get the FREE Ultimate OpenClaw Setup Guide →

riligar-dev-database

npx machina-cli add skill riligar/agents-kit/riligar-dev-database --openclaw
Files (1)
SKILL.md
2.0 KB

database — Drizzle + bun:sqlite

SQLite nativo no Bun. Zero drivers externos. Base de dados no volume do Fly.io (/app/data).

Referências

ArquivoQuando usar
connection.mdSetup inicial: instalação, db.js, drizzle.config
schema.mdDefinir tabelas, tipos de colunas, relações
migrations.mdCriar e executar migrations com drizzle-kit
queries.mdSelect, insert, update, delete, queries com relações

Quick Start

// database/db.js
import { drizzle } from 'drizzle-orm/bun-sqlite'
import database from 'bun:sqlite'

const sqlite = new database(process.env.DB_PATH ?? './database/database.db')
const db = drizzle({ client: sqlite })

export { db }

Regras

  • Caminho do banco: /app/data/database.db em produção (volume Fly.io). ./database/database.db em desenvolvimento.
  • Migrations sempre: Use drizzle-kit generate + drizzle-kit migrate. Nunca edite migrations à mão.
  • Schema único: Todas as tabelas em database/schema.js.
  • Migrations no startup: Use migrate() no index.js antes de .listen().

Related Skills

NeedSkill
Backend (Elysia)@[.agent/skills/riligar-dev-manager]
Payments (Stripe)@[.agent/skills/riligar-infra-stripe]
Infrastructure@[.agent/skills/riligar-infra-fly]

Source

git clone https://github.com/riligar/agents-kit/blob/prod/.agent/skills/riligar-dev-database/SKILL.mdView on GitHub

Overview

This skill covers using Drizzle ORM with bun:sqlite for RiLiGar. It teaches how to set up database connections, define schemas, create migrations, and write queries, all within the drizzle-kit workflow and specifically for SQLite on Fly.io volumes.

How This Skill Works

The setup uses Bun's native SQLite driver via drizzle-orm/bun-sqlite. You create a DB client with drizzle({ client: sqlite }), targeting /app/data/database.db in production or ./database/database.db in development, and export the db object for queries and migrations. Schema definitions live in a central database/schema.js and migrations are managed with drizzle-kit as part of the startup workflow.

When to Use It

  • Initializing RiLiGar database connections and boilerplate for a new project.
  • Defining tables, column types, and relationships in a single schema.js.
  • Creating and applying migrations with drizzle-kit (generate + migrate).
  • Writing queries (select, insert, update, delete) and handling relations with Drizzle.
  • Deploying SQLite on Fly.io with a persistent volume at /app/data/database.db using the drizzle-kit workflow.

Quick Start

  1. Step 1: Import { drizzle } from 'drizzle-orm/bun-sqlite' and Bun's sqlite driver (bun:sqlite).
  2. Step 2: Create the SQLite instance: const sqlite = new database(process.env.DB_PATH ?? './database/database.db').
  3. Step 3: Wire up Drizzle and export: const db = drizzle({ client: sqlite }); export { db }

Best Practices

  • Production path: /app/data/database.db; development path: ./database/database.db.
  • Always run migrations on startup with migrate() before the app starts listening.
  • Keep all tables and schema in a single source: database/schema.js.
  • Never edit migrations manually; rely on drizzle-kit generate and migrate.
  • Consult the Referências docs for connection, schema, migrations, and queries as a guided pattern.

Example Use Cases

  • database/db.js showing the drizzle setup with bun-sqlite and a shared db export.
  • Using process.env.DB_PATH with a default to ./database/database.db for development.
  • Starting the app with migrate() invoked during startup before index.js.listen().
  • Centralized schema definitions in database/schema.js for all tables.
  • Deployment on Fly.io using /app/data/database.db as the persistent volume.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers