docs: refresh readme and legal info

This commit is contained in:
2026-05-07 20:22:12 +00:00
parent 5fbe2eb80b
commit 7bb6559748
6 changed files with 287 additions and 243 deletions
+55 -29
View File
@@ -1,63 +1,89 @@
# @serve.zone/dcrouter-migrations
Versioned SmartMigration chain for dcrouter's persistent data. This package builds the migration runner that dcrouter executes before DB-backed managers start reading collections.
`@serve.zone/dcrouter-migrations` is dcrouter's versioned SmartMigration chain for persistent database schema and data transitions. The main dcrouter runtime runs it after the database is ready and before DB-backed managers read collections.
## Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
## Installation
## Install
```bash
pnpm add @serve.zone/dcrouter-migrations
```
## What It Exports
If you boot `DcRouter`, you usually do not install or call this package directly; startup handles it.
## API
| Export | Purpose |
| --- | --- |
| `createMigrationRunner(db, targetVersion)` | Builds the dcrouter migration runner for the target application version |
| `IMigrationRunner` | Small interface for the returned runner |
| `IMigrationRunResult` | Result shape logged after a run |
## When To Use It
- You are embedding dcrouter's storage layer outside the full runtime.
- You want to test or inspect schema transitions directly.
- You are extending dcrouter with new persistent data and need versioned upgrades.
If you boot the full `DcRouter` runtime, this package is already used for you during startup.
## Usage
| `createMigrationRunner(db, targetVersion)` | Builds a configured SmartMigration runner for the supplied Smartdata database and target app version. |
| `IMigrationRunner` | Minimal runner interface with `run()`. |
| `IMigrationRunResult` | Result shape logged after a migration run. |
```typescript
import { createMigrationRunner } from '@serve.zone/dcrouter-migrations';
const migration = await createMigrationRunner(db, '13.20.0');
const migration = await createMigrationRunner(db, '13.25.0');
const result = await migration.run();
console.log(result.currentVersionBefore, result.currentVersionAfter);
```
## What the Current Chain Covers
## Current Chain
- target profile target field migration from `host` to `ip`
- legacy domain source rename from `manual` to `dcrouter`
- legacy DNS record source rename from `manual` to `local`
- route storage unification from `StoredRouteDoc` to `RouteDoc`
The current migration chain covers:
- `TargetProfileDoc.targets[].host` to `TargetProfileDoc.targets[].ip`
- legacy domain source `manual` to `dcrouter`
- legacy DNS record source `manual` to `local`
- route collection unification from `StoredRouteDoc` to `RouteDoc`
- route `origin` backfill for migrated API routes
- `systemKey` backfill for persisted config, email, and DNS routes
## Authoring Rules
## Migration Rules
- Add new migration logic only in `ts_migrations/index.ts`.
- Keep every step idempotent so reruns are safe.
- Make each step's `.to()` version line up with the release version that ships it.
- When adding new collection references, use the exact smartdata class-name collection casing for new code.
All schema migrations must live in `ts_migrations/index.ts` as SmartMigration steps. Do not put migration logic in application services, managers, startup hooks, or document classes.
Every step must be idempotent. SmartMigration may re-run steps during skip-forward or resume flows, so an already-migrated database must remain safe.
The `.to()` version of a step must match the release version that ships the migration so SmartMigration can plan the step correctly.
## Collection Name Warning
smartdata uses the exact class name as the MongoDB collection name. Do not lowercase new collection references.
Examples:
| Document class | MongoDB collection |
| --- | --- |
| `StoredRouteDoc` | `StoredRouteDoc` |
| `TargetProfileDoc` | `TargetProfileDoc` |
| `RouteDoc` | `RouteDoc` |
When writing migrations in `ts_migrations/index.ts`, use exact class-name casing in calls such as `ctx.mongo!.collection('ClassName')` and `db.listCollections({ name: 'ClassName' })`.
Historical migration steps may still reference older lowercased collections from earlier behavior. Do not copy that pattern for new migrations.
## When To Use This Package Directly
- You are testing dcrouter schema transitions without booting the full runtime.
- You are embedding dcrouter persistence in another process and need the same version chain.
- You are authoring a migration and want a focused test harness around `createMigrationRunner()`.
## Development
This folder is published from the dcrouter monorepo via `tspublish.json` with order `2`.
Useful source entry points:
- `index.ts` defines the public runner factory and all migration steps.
- `../AGENTS.md` contains the local migration authoring rules that must be followed.
## License and Legal Information
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](../license) file.
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](../license) file.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
@@ -69,7 +95,7 @@ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark G
### Company Information
Task Venture Capital GmbH
Task Venture Capital GmbH
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or further information, please contact us via email at hello@task.vc.