You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/stack-forge/README.md
+79-5Lines changed: 79 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,8 @@ bun add -D @cipherstash/stack-forge
30
30
31
31
## Quick Start
32
32
33
+
You can install EQL in two ways: **direct install** (connects to the DB and runs the SQL) or **Drizzle migration** (generates a migration file; you run `drizzle-kit migrate` yourself). The steps below use the direct install path.
34
+
33
35
### 1. Create a config file
34
36
35
37
Create `stash.config.ts` in your project root:
@@ -56,6 +58,10 @@ npx stash-forge install
56
58
57
59
That's it. EQL is now installed in your database.
58
60
61
+
If your encryption client lives elsewhere, set `client` in `stash.config.ts` (e.g. `client: './lib/encryption.ts'`). That path is used by `stash-forge push`.
62
+
63
+
**Using Drizzle?** To install EQL via your migration pipeline instead, run `npx stash-forge install --drizzle`, then `npx drizzle-kit migrate`. See [install --drizzle](#install---drizzle) below.
64
+
59
65
---
60
66
61
67
## Configuration
@@ -68,9 +74,24 @@ import { defineConfig } from '@cipherstash/stack-forge'
68
74
exportdefaultdefineConfig({
69
75
// Required: PostgreSQL connection string
70
76
databaseUrl: process.env.DATABASE_URL!,
77
+
78
+
// Optional: path to your encryption client (default: './src/encryption/index.ts')
79
+
// Used by `stash-forge push` to load the encryption schema
80
+
client: './src/encryption/index.ts',
81
+
82
+
// Optional: CipherStash workspace and credentials (for future schema sync)
|`--exclude-operator-family`| Skip operator family creation (for non-superuser database roles) |
121
+
|`--drizzle`| Generate a Drizzle migration instead of direct install |
122
+
|`--name <value>`| Migration name when using `--drizzle` (default: `install-eql`) |
123
+
|`--out <value>`| Drizzle output directory when using `--drizzle` (default: `drizzle`) |
100
124
101
125
**Standard install:**
102
126
@@ -120,7 +144,57 @@ The `--supabase` flag:
120
144
npx stash-forge install --dry-run
121
145
```
122
146
123
-
### Permission Pre-checks
147
+
#### `install --drizzle`
148
+
149
+
If you use [Drizzle ORM](https://orm.drizzle.team/) and want EQL installation as part of your migration history, use the `--drizzle` flag. It creates a Drizzle migration file containing the EQL install SQL, then you run your normal Drizzle migrations to apply it.
150
+
151
+
```bash
152
+
npx stash-forge install --drizzle
153
+
npx drizzle-kit migrate
154
+
```
155
+
156
+
**How it works:**
157
+
158
+
1. Runs `drizzle-kit generate --custom --name=<name>` to create an empty migration.
159
+
2. Downloads the EQL install script from the [EQL GitHub releases](https://github.com/cipherstash/encrypt-query-language/releases/latest).
160
+
3. Writes the EQL SQL into the generated migration file.
You need `drizzle-kit` installed in your project (`npm install -D drizzle-kit`). The `--out` directory must match your Drizzle config (e.g. `drizzle.config.ts`).
170
+
171
+
### `push`
172
+
173
+
Load your encryption schema from the file specified by `client` in `stash.config.ts` and apply it to the database (or preview with `--dry-run`).
174
+
175
+
```bash
176
+
npx stash-forge push [options]
177
+
```
178
+
179
+
| Option | Description |
180
+
|--------|-------------|
181
+
|`--dry-run`| Load and validate the schema, then print it as JSON. No database changes. |
182
+
183
+
**Push schema to the database:**
184
+
185
+
```bash
186
+
npx stash-forge push
187
+
```
188
+
189
+
This connects to Postgres, marks any existing rows in `eql_v2_configuration` as `inactive`, and inserts the current encrypt config as a new row with state `active`. Your runtime encryption (e.g. `@cipherstash/stack`) reads the active configuration from this table.
190
+
191
+
**Preview your encryption schema without writing to the database:**
192
+
193
+
```bash
194
+
npx stash-forge push --dry-run
195
+
```
196
+
197
+
### Permission Pre-checks (install)
124
198
125
199
Before installing, `stash-forge` verifies that the connected database role has the required permissions:
126
200
@@ -137,8 +211,7 @@ The following commands are defined but not yet implemented:
137
211
| Command | Description |
138
212
|---------|-------------|
139
213
|`init`| Initialize CipherStash Forge in your project |
140
-
|`push`| Push encryption schema to database |
141
-
|`migrate`| Run pending EQL migrations |
214
+
|`migrate`| Run pending encrypt config migrations |
0 commit comments