nocobase-db
What it does
This skill guides your AI through the database layer of a NocoBase 3 app. It is for developers who add tables, migrations, or data logic to an app.
When to use it
- ✓When you need to add or change a table or field in a NocoBase 3 app.
- ✓When you write code that reads or saves records and needs transactions.
- ✓When you configure a database connection or write a migration or seed.
Skill link
https://github.com/nocobase/nocobase/blob/v3-develop/packages/libs/db/skills/nocobase-db/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Can you add an orders table linked to customers in my NocoBase app, using a migration?”
5 new skills a week. 1 minute to read.
How it works
The AI chooses the right layer for the task: configuration, migrations, the schema builder, or the runtime repository. It then writes the code with the correct API and transaction handling.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
The database in a NocoBase 3 application
Most mistakes here are made before the first line of code, by putting a task at the wrong layer: changing schema from runtime code, reading records through the schema builder, or reimplementing relation writes on top of raw queries.
Six areas, in the order an application grows into them:
| Area | Owns |
|---|---|
| Configuration | which databases exist, and which dialect each one speaks |
| Migrations and seeds | schema history and install data |
| Builder | how a migration declares tables, fields and constraints |
| Repository and Query | runtime reads and writes |
| Transactions | making several writes succeed or fail together |
| Collections | what the database actually resolves to, for code and for you |
The exact parameters and return types are always the TypeScript declarations in @nocobase/db. This Skill decides which API to reach for, where the code belongs, and the boundaries the types cannot express.
Where the code lives
server/config/database.ts connections and the default connection
config.yml per-environment overrides and credentials (gitignored)
database/<connection>/migrations schema history for that connection
database/<connection>/seeds install data for that connection
database/<connection>/collections resolved Collection artifacts
server/routes/, server/providers runtime reads and writes
<connection> is a connection name from server/config/database.ts, so the default connection's migrations are in database/main/migrations/. Adding a connection means adding its directory alongside and keeping database/tsconfig.json in place, so migrations and seeds are typechecked and linted as server source.
Runtime code never changes schema, and a migration never imports runtime code. That split is what these directories encode.
1. Configuration
Connections are declared in code and overridden per environment:
| Location | Responsibility |
|---|---|
server/config/database.ts |
Connection defaults through defineAppDatabaseConfig |
config.yml |
Environment overrides including credentials — gitignored |
config.example.yml |
The documented structure and credential placeholders; keep it in step |
import {
connectionEnvironment,
defineAppDatabaseConfig,
} from '@nocobase/app-server/database';
export default defineAppDatabaseConfig(
({ paths }) => ({
default: 'main',
connections: {
main: {
dialect: 'sqlite',
filename: paths.storage('database.sqlite'),
schemaManagement: 'managed',
debug: false,
},
},
}),
{ env: connectionEnvironment('main') },
);
The second argument maps environment variables onto the section: connectionEnvironment('main') declares DB_DIALECT, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD, DB_SSL and DB_FILENAME for the main connection, each overriding config.yml. Only main has them; a connection you add declares its own with a prefix naming it, connectionEnvironment('analytics', 'DB_ANALYTICS'), merged into the same env.
The dialects are sqlite, postgres, mysql, mssql, oracle, dameng, kingbase and oceanbase. Each is an optional peer of @nocobase/app-server shipped as its own package: install @nocobase/db-<dialect> into dependencies — so it reaches the deployed server — and configure the dialect. No import or driver registration is needed, and the dialect package brings its own underlying driver.
Switching a dialect means changing both layers. config.yml deep-merges into the code defaults, so editing only the code leaves a stale YAML override in place — with fields belonging to the previous dialect still applied. Remove filename
FAQ
Can I change tables from normal runtime code?
The skill says table changes belong in migrations, not in runtime code.
Is this for NocoBase 2?
No. NocoBase 2 uses a different database package.
What is a seed?
A seed fills the database with install data that the app needs to start.
Details
Original description by the author
Work with the database in a NocoBase 3 application: configure connections and dialects, add migrations and seeds, declare schema with the Collection Builder, read and write records with Repository or QueryAdapter, run transactions, and read Collection definitions. Use for any task under database/ or any server code that touches data. Do not use for the NocoBase 2 @nocobase/database package.
repo: nocobase/nocobase
Popularity
- GitHub stars
- 25k
- Ranking position
- #10083
- License
- —
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
nocobase-app-development
25kHelps your agent build pages, routes, data, permissions, and tests for a complete NocoBase 3 business application.
shadcn
25kHelps your agent find, add, fix, and style shadcn/ui components in a web project, using their official docs and registries.
nocobase-app-plugin-development
25kHelps your agent create and maintain NocoBase 3 plugins inside an existing app, including server, client, database, and registration parts.
nocobase-app-upgrade
25kHelps your agent upgrade a NocoBase app to a newer template release, bringing in template changes while keeping your own work.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.