@sedrino/db-schema 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/dist/index.d.ts +1222 -0
- package/dist/index.js +1456 -0
- package/dist/index.js.map +1 -0
- package/docs/cli.md +70 -0
- package/docs/index.md +11 -0
- package/docs/migrations.md +65 -0
- package/docs/schema-document.md +48 -0
- package/package.json +41 -0
- package/src/apply.ts +234 -0
- package/src/cli.ts +209 -0
- package/src/drizzle.ts +178 -0
- package/src/index.ts +62 -0
- package/src/migration.ts +456 -0
- package/src/planner.ts +247 -0
- package/src/project.ts +79 -0
- package/src/schema.ts +53 -0
- package/src/sqlite.ts +172 -0
- package/src/types.ts +145 -0
- package/src/utils.ts +286 -0
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @sedrino/db-schema
|
|
2
|
+
|
|
3
|
+
Migration-first schema planning for AI-authored SQLite/libSQL databases.
|
|
4
|
+
|
|
5
|
+
This package is aimed at a workflow where:
|
|
6
|
+
|
|
7
|
+
1. AI or humans author migrations in a deterministic TypeScript DSL
|
|
8
|
+
2. the planner materializes the next schema snapshot JSON
|
|
9
|
+
3. the compiler emits generated artifacts such as Drizzle schema code
|
|
10
|
+
|
|
11
|
+
## Current scope
|
|
12
|
+
|
|
13
|
+
The first version focuses on the planning layer:
|
|
14
|
+
|
|
15
|
+
- versioned schema document types
|
|
16
|
+
- migration DSL with deterministic operation recording
|
|
17
|
+
- schema materialization from migration history
|
|
18
|
+
- SQLite DDL emission
|
|
19
|
+
- Drizzle source generation for a narrow SQLite + Temporal-aware subset
|
|
20
|
+
- a libSQL-compatible apply runner with migration/state metadata tables
|
|
21
|
+
- a Bun-first CLI for planning migrations, applying them, and emitting schema artifacts
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
bun add @sedrino/db-schema
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Example
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import {
|
|
33
|
+
compileSchemaToDrizzle,
|
|
34
|
+
createMigration,
|
|
35
|
+
planMigration,
|
|
36
|
+
} from "@sedrino/db-schema";
|
|
37
|
+
|
|
38
|
+
const migration = createMigration(
|
|
39
|
+
{
|
|
40
|
+
id: "2026-04-08-001-create-account",
|
|
41
|
+
name: "Create account table",
|
|
42
|
+
},
|
|
43
|
+
(m) => {
|
|
44
|
+
m.createTable("account", (t) => {
|
|
45
|
+
t.id("accountId", { prefix: "acct" });
|
|
46
|
+
t.string("name").required();
|
|
47
|
+
t.temporalInstant("createdAt").required().defaultNow();
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const plan = planMigration({ migration });
|
|
53
|
+
const drizzleSource = compileSchemaToDrizzle(plan.nextSchema);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Docs
|
|
57
|
+
|
|
58
|
+
- `docs/index.md`
|
|
59
|
+
- `docs/schema-document.md`
|
|
60
|
+
- `docs/migrations.md`
|
|
61
|
+
|
|
62
|
+
## CLI
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
sedrino-db migrate plan --dir db
|
|
66
|
+
sedrino-db migrate apply --dir db --url file:./local.db
|
|
67
|
+
sedrino-db schema print --dir db
|
|
68
|
+
sedrino-db schema drizzle --dir db --out db/schema/schema.generated.ts
|
|
69
|
+
```
|