@authhero/drizzle 0.5.2 → 0.6.0
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 +64 -2
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
# @authhero/drizzle
|
|
1
|
+
# @authhero/drizzle
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Drizzle ORM schemas for AuthHero - used for **migration generation only**.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This package provides Drizzle ORM schema definitions for generating database migrations. AuthHero uses:
|
|
8
|
+
|
|
9
|
+
- **Kysely** for runtime queries (single schema works across SQLite/MySQL/PostgreSQL)
|
|
10
|
+
- **Drizzle** for migration generation (native D1/SQLite support with proper diff migrations)
|
|
11
|
+
|
|
12
|
+
## Available Schemas
|
|
13
|
+
|
|
14
|
+
### SQLite/D1
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import * as schema from "@authhero/drizzle/sqlite";
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Designed for Cloudflare D1 and SQLite databases.
|
|
21
|
+
|
|
22
|
+
## Generating Migrations
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Generate a new migration
|
|
26
|
+
pnpm db:generate
|
|
27
|
+
|
|
28
|
+
# Push changes directly (development only)
|
|
29
|
+
pnpm db:push
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Migrations are output to `./drizzle/sqlite/`.
|
|
33
|
+
|
|
34
|
+
## Why This Approach?
|
|
35
|
+
|
|
36
|
+
| Tool | Role | Why |
|
|
37
|
+
|------|------|-----|
|
|
38
|
+
| **Kysely** | Runtime queries | Single schema works across all dialects |
|
|
39
|
+
| **Drizzle** | Migration generation | Native D1 support, automatic diff migrations |
|
|
40
|
+
|
|
41
|
+
Drizzle requires separate schema definitions per dialect, so we maintain a SQLite schema here specifically for D1 migration generation. The Kysely adapter handles runtime database operations.
|
|
42
|
+
|
|
43
|
+
## Usage with create-authhero
|
|
44
|
+
|
|
45
|
+
The `cloudflare-simple` template uses pre-generated migrations from this schema. Users can:
|
|
46
|
+
|
|
47
|
+
1. Use the initial migration as-is for a fresh database
|
|
48
|
+
2. Modify the Drizzle schema and run `pnpm db:generate` for incremental changes
|
|
49
|
+
|
|
50
|
+
## Schema Files
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
src/schema/sqlite/
|
|
54
|
+
├── index.ts # Main export
|
|
55
|
+
├── tenants.ts # Tenant tables
|
|
56
|
+
├── users.ts # User & password tables
|
|
57
|
+
├── clients.ts # Client & grant tables
|
|
58
|
+
├── connections.ts # Connection & domain tables
|
|
59
|
+
├── sessions.ts # Session, token & code tables
|
|
60
|
+
├── organizations.ts # Organization tables
|
|
61
|
+
├── roles.ts # Role & permission tables
|
|
62
|
+
├── branding.ts # Branding, theme & UI tables
|
|
63
|
+
├── logs.ts # Log tables
|
|
64
|
+
└── legacy.ts # Legacy/deprecated tables
|
|
65
|
+
```
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/markusahlstrand/authhero"
|
|
13
13
|
},
|
|
14
|
-
"version": "0.
|
|
14
|
+
"version": "0.6.0",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
@@ -35,9 +35,11 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"drizzle-orm": "^0.44.2",
|
|
38
|
-
"@authhero/adapter-interfaces": "0.
|
|
38
|
+
"@authhero/adapter-interfaces": "0.111.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
-
"build": "tsc && vite build"
|
|
41
|
+
"build": "tsc && vite build",
|
|
42
|
+
"db:generate": "drizzle-kit generate",
|
|
43
|
+
"db:push": "drizzle-kit push"
|
|
42
44
|
}
|
|
43
45
|
}
|