@deterministic-code/migraters

中文文档
0.0.19发布于 2026/11/07ES Module近 30 天下载 4185

Migrate executables for deterministic-code (typescript, rust, csharp).

原始使用文档
文档目录15 节
  1. Install skill
  2. Install
  3. Install from npm
  4. Skill Prompts
  5. Quick example
  6. Commands
  7. init
  8. setup
  9. up
  10. down
  11. create
  12. API
  13. Language support
  14. Providers
  15. Specification

Migraters

CI

Migraters allows you to save SQL changes during development so they can be applied upstream later. As a codebase grows in complexity and team size, keeping those changes tracked and in sync becomes harder. Migraters is built for that.

The typical workflow is:

  • On development, create one or more migration files, test them, and run migrate up.
  • On deploy, those scripts are copied to production and migrate up is run again, so the upstream database matches development.

The migrate commands are available in many languages and support many SQL dialects.

Install skill

Agent skill for Claude or Cursor: skill/SKILL.md.

npx skills add https://github.com/deterministic-code/migraters/tree/main/skill -g -a cursor -a claude-code -y --copy

Install

Install from npm

npm install @deterministic-code/migraters

Skill Prompts

Natural-language prompts the skill maps straight to CLI commands:

PromptRuns
Install migraters for sqlite and postgresnpm install → npx migrate-init --language typescript --dialect sqlite --dialect postgres
Add driver oraclenpx migrate-init --language <language> with prior dialects plus oracle
Create a new migratenpx migrate-create
migrate upnpx migrate-up
migrate downnpx migrate-down

Quick example

user.sql:

CREATE TABLE users (
  id INTEGER PRIMARY KEY,
  email TEXT NOT NULL
);
npx migrate-init --language typescript --dialect sqlite
npx migrate-setup --provider sqlite --connection ./app.sqlite
npx migrate-create --provider sqlite --name add_users
touch user.sql
cat user.sql > sql/sqlite/migrations/0001_add_users_up.sql
npx migrate-up --provider sqlite --connection ./app.sqlite

Commands

init

The migrate-init command installs language and datasource dependencies and builds the migrate commands.

npx migrate-init --language typescript --dialect sqlite --dialect postgres
npx migrate-init --language csharp --dialect sqlite
npx migrate-init --language rust --dialect sqlite

setup

Creates the migrates and migrate_logs tables and the migrations directory. Idempotent.

npx migrate-setup --provider <sqlite|postgres|mysql|sqlserver|oracle> --connection <url> [--migrations-path <dir>] [--and-up] [--create-database] [--batch-separator <token>]

--create-database creates the database named in --connection if it does not exist. --and-up runs migrate-up immediately after setup. Default migrations directory is ./sql/<dialect>/migrations.

up

Applies every pending migration, each in its own transaction.

npx migrate-up --provider <…> --connection <url> [--migrations-path <dir>] [--migrations-root <dir>] [--one] [--batch-separator <token>]

--migrations-root looks under <root>/<dialect>/migrations and defaults to sql. It is ignored when --migrations-path is set. --one applies only the next pending migration. A batch-separator line starts with GO by default (sqlcmd-style), or with --batch-separator. A trailing -- comment or YYYY-MM-DD date is allowed. Each batch is executed separately.

down

Rolls back the most recently applied migration, one step. Type confirm at the prompt, or pass --confirm.

npx migrate-down --provider <…> --connection <url> [--migrations-path <dir>] [--migrations-root <dir>] [--confirm] [--batch-separator <token>]

create

Writes the next <NNNN>_<name>_up.sql and <NNNN>_<name>_down.sql pair. The name must match ^[a-z][a-z0-9_]*$.

npx migrate-create --provider <…> --name <snake_case_slug> [--migrations-path <dir>]

API

The four IMigrater verbs are one contract in every language: argv in cli.yaml, IMigrater in api.yaml. Each language implements that interface. Catalog insert and delete stay inside up and down. migrate-init lives only in cli.yaml.

VerbTypeScript IMigraterRust IMigraterC# IMigrater
setupsetupsetupSetup
upupupUp
downdowndownDown
createcreatecreateCreate

Language support

DatasourceC#RustTypeScript
sqliteyesyesyes
postgresyesyesyes
mysqlyesyesyes
sqlserveryesyesyes
oracleyesyesyes

Providers

sqlite, postgres, mysql, sqlserver, and oracle.

When --connection is omitted, the runner reads the first set environment variable for that dialect:

ProviderEnvironment variables
sqliteSQLITE_PATH, DB_PATH
postgresPG_CONNECTION_STRING, DATABASE_URL
mysqlMYSQL_URL, DATABASE_URL
sqlserverMSSQL_URL, DATABASE_URL
oracleORACLE_CONNECT_STRING, DATABASE_URL

Specification

Shared argv, flags, aliases, exit codes, and command behavior live in cli.yaml. IMigrater (setup, up, down, create) lives in api.yaml. migrate-init is CLI-only. SQL spelling stays a provider detail.

版本与发布记录

@deterministic-code/migraters 共发布 20 个版本,首次发布于 2026/10/20;过去 12 个月发布了 20 个版本。

版本发布日期距今
0.0.19latest2026/11/075 天前
0.0.182026/11/065 天前
0.0.172026/11/065 天前
0.0.162026/11/056 天前
0.0.152026/11/056 天前
0.0.142026/11/056 天前

关于 @deterministic-code/migraters 的常见问题

@deterministic-code/migraters 是什么?

Migrate executables for deterministic-code (typescript, rust, csharp).

如何安装 @deterministic-code/migraters?

在项目目录运行 npm install @deterministic-code/migraters,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 migrate-up、migrate-down、migrate-init、migrate-setup、migrate-create,可以用 npx migrate-up 直接运行。

@deterministic-code/migraters 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/deterministic-code__migraters 是否存在。

@deterministic-code/migraters 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@deterministic-code/migraters 可以商用吗?

@deterministic-code/migraters 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@deterministic-code/migraters 的下载量有多少?

根据 npm 官方下载统计,@deterministic-code/migraters 在 2026/10/12 – 2026/11/10 这 30 天内被下载 4,185 次,日均约 140 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@deterministic-code/migraters 还在维护吗?

最新版本 0.0.19 发布于 2026/11/07(5 天前);至今共发布 20 个版本,其中过去 12 个月发布了 20 个;首次发布于 2026/10/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。