@alchemy.run/drizzle 0.0.0 → 2.0.0-beta.84
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/LICENSE +201 -0
- package/README.md +82 -4
- package/lib/Cloudflare.d.ts +104 -0
- package/lib/Cloudflare.d.ts.map +1 -0
- package/lib/Cloudflare.js +118 -0
- package/lib/Cloudflare.js.map +1 -0
- package/lib/D1.d.ts +48 -0
- package/lib/D1.d.ts.map +1 -0
- package/lib/D1.js +50 -0
- package/lib/D1.js.map +1 -0
- package/lib/LibSQL.d.ts +45 -0
- package/lib/LibSQL.d.ts.map +1 -0
- package/lib/LibSQL.js +47 -0
- package/lib/LibSQL.js.map +1 -0
- package/lib/MySQL.d.ts +45 -0
- package/lib/MySQL.d.ts.map +1 -0
- package/lib/MySQL.js +42 -0
- package/lib/MySQL.js.map +1 -0
- package/lib/Postgres.d.ts +62 -0
- package/lib/Postgres.d.ts.map +1 -0
- package/lib/Postgres.js +59 -0
- package/lib/Postgres.js.map +1 -0
- package/lib/Providers.d.ts +47 -0
- package/lib/Providers.d.ts.map +1 -0
- package/lib/Providers.js +45 -0
- package/lib/Providers.js.map +1 -0
- package/lib/Schema.d.ts +85 -0
- package/lib/Schema.d.ts.map +1 -0
- package/lib/Schema.js +372 -0
- package/lib/Schema.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +14 -0
- package/lib/index.js.map +1 -0
- package/package.json +78 -3
- package/src/Cloudflare.ts +146 -0
- package/src/D1.ts +77 -0
- package/src/LibSQL.ts +78 -0
- package/src/MySQL.ts +86 -0
- package/src/Postgres.ts +100 -0
- package/src/Providers.ts +51 -0
- package/src/Schema.ts +504 -0
- package/src/index.ts +19 -0
package/lib/Schema.js
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import * as crypto from "node:crypto";
|
|
10
|
+
import * as Artifacts from "alchemy/Artifacts";
|
|
11
|
+
import { isResolved } from "alchemy/Diff";
|
|
12
|
+
import * as Provider from "alchemy/Provider";
|
|
13
|
+
import { Resource } from "alchemy/Resource";
|
|
14
|
+
import { exec } from "alchemy/Util/exec";
|
|
15
|
+
import { isNonInteractive } from "alchemy/Util/interactive";
|
|
16
|
+
import * as Effect from "effect/Effect";
|
|
17
|
+
import * as FileSystem from "effect/FileSystem";
|
|
18
|
+
import * as Path from "effect/Path";
|
|
19
|
+
import { ChildProcess } from "effect/process";
|
|
20
|
+
/**
|
|
21
|
+
* A Drizzle schema managed as an Alchemy resource.
|
|
22
|
+
*
|
|
23
|
+
* Wraps drizzle-kit's programmatic API (`generateDrizzleJson` /
|
|
24
|
+
* `generateMigration`) so migration SQL is regenerated as part of `alchemy
|
|
25
|
+
* deploy` whenever the source schema changes. The output directory is
|
|
26
|
+
* intended to be passed straight to a database resource's `migrations`
|
|
27
|
+
* prop, giving you a single deploy-driven flow:
|
|
28
|
+
*
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const schema = yield* Drizzle.Schema("app-schema", {
|
|
31
|
+
* schema: "./src/schema.ts",
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const branch = yield* Neon.Branch("app-branch", {
|
|
35
|
+
* project,
|
|
36
|
+
* migrations: schema,
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* const db = yield* Fly.Postgres("Db", {
|
|
40
|
+
* region: "iad",
|
|
41
|
+
* migrations: schema,
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* `Drizzle.Schema` runs first (because the database resource depends
|
|
46
|
+
* on its `out` output), regenerates pending migration files, and the
|
|
47
|
+
* database resource then applies them.
|
|
48
|
+
*
|
|
49
|
+
* The resource is delete-safe: removing it from the stack does **not** wipe
|
|
50
|
+
* the migrations directory, since migration files are typically checked in
|
|
51
|
+
* and shared with other environments.
|
|
52
|
+
*
|
|
53
|
+
* @resource
|
|
54
|
+
*/
|
|
55
|
+
export const Schema = Resource("Drizzle.Schema");
|
|
56
|
+
const dialectModule = (dialect) => {
|
|
57
|
+
switch (dialect) {
|
|
58
|
+
case "postgres":
|
|
59
|
+
return "drizzle-kit/api-postgres";
|
|
60
|
+
case "mysql":
|
|
61
|
+
return "drizzle-kit/api-mysql";
|
|
62
|
+
case "sqlite":
|
|
63
|
+
return "drizzle-kit/api-sqlite";
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const sha = (s) => crypto.createHash("sha256").update(s).digest("hex");
|
|
67
|
+
const tsStamp = () => new Date().toISOString().replace(/[-:T]/g, "").slice(0, 14);
|
|
68
|
+
export const SchemaProvider = () => Provider.effect(Schema, Effect.gen(function* () {
|
|
69
|
+
const fs = yield* FileSystem.FileSystem;
|
|
70
|
+
const path = yield* Path.Path;
|
|
71
|
+
const resolveOut = (p) => path.resolve(process.cwd(), p.out ?? "./migrations");
|
|
72
|
+
// The `out` attribute is exposed as a path relative to the current
|
|
73
|
+
// working directory so that persisted state stays portable across
|
|
74
|
+
// machines/checkouts. Internal filesystem ops always use the absolute
|
|
75
|
+
// `resolveOut` form.
|
|
76
|
+
const relativeOut = (abs) => path.relative(process.cwd(), abs);
|
|
77
|
+
const resolveSchema = (p) => path.resolve(process.cwd(), p.schema);
|
|
78
|
+
const loadSchemaModule = (p) => Effect.gen(function* () {
|
|
79
|
+
const schemaPath = resolveSchema(p);
|
|
80
|
+
return yield* Effect.tryPromise({
|
|
81
|
+
try: () => import(__rewriteRelativeImportExtension(/* @vite-ignore */ schemaPath)),
|
|
82
|
+
catch: (cause) => new Error(`Failed to import schema at ${p.schema}: ${cause}`),
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
const loadKit = (dialect) => Effect.tryPromise({
|
|
86
|
+
try: () => import(__rewriteRelativeImportExtension(/* @vite-ignore */ dialectModule(dialect))),
|
|
87
|
+
catch: (cause) => new Error(`Failed to load drizzle-kit/${dialect} (is drizzle-kit installed?): ${cause}`),
|
|
88
|
+
});
|
|
89
|
+
const drizzleKitBin = (dialect) => Effect.gen(function* () {
|
|
90
|
+
const apiUrl = yield* Effect.try({
|
|
91
|
+
try: () => import.meta.resolve(dialectModule(dialect)),
|
|
92
|
+
catch: (cause) => new Error(`Failed to resolve drizzle-kit/${dialect}: ${cause}`),
|
|
93
|
+
});
|
|
94
|
+
const apiFileUrl = yield* Effect.try({
|
|
95
|
+
try: () => new URL(apiUrl),
|
|
96
|
+
catch: (cause) => new Error(`Failed to parse drizzle-kit/${dialect} URL: ${cause}`),
|
|
97
|
+
});
|
|
98
|
+
const apiPath = yield* path.fromFileUrl(apiFileUrl);
|
|
99
|
+
return path.join(path.dirname(apiPath), "bin.cjs");
|
|
100
|
+
});
|
|
101
|
+
const runDrizzleGenerate = (props, out) => Effect.gen(function* () {
|
|
102
|
+
const dialect = props.dialect ?? "postgres";
|
|
103
|
+
const bin = yield* drizzleKitBin(dialect);
|
|
104
|
+
const schemaPath = resolveSchema(props);
|
|
105
|
+
const nodeExecPath = yield* Effect.sync(() => process.execPath);
|
|
106
|
+
const nodeModulesPath = path.join(process.cwd(), "node_modules");
|
|
107
|
+
// drizzle-kit globs the --schema/--out values; Windows backslashes
|
|
108
|
+
// are treated as glob escapes and match nothing, so pass forward
|
|
109
|
+
// slashes.
|
|
110
|
+
const args = [
|
|
111
|
+
bin,
|
|
112
|
+
"generate",
|
|
113
|
+
"--dialect",
|
|
114
|
+
dialect === "postgres" ? "postgresql" : dialect,
|
|
115
|
+
"--schema",
|
|
116
|
+
schemaPath.replaceAll("\\", "/"),
|
|
117
|
+
"--out",
|
|
118
|
+
out.replaceAll("\\", "/"),
|
|
119
|
+
];
|
|
120
|
+
const commandOptions = {
|
|
121
|
+
cwd: process.cwd(),
|
|
122
|
+
env: { NODE_PATH: nodeModulesPath },
|
|
123
|
+
extendEnv: true,
|
|
124
|
+
};
|
|
125
|
+
// Hand the terminal to drizzle-kit only when this process may
|
|
126
|
+
// prompt at all — the same detection (TTY, CI, `--no-input`,
|
|
127
|
+
// `ALCHEMY_NO_TUI`, agent env) every other spawned command uses.
|
|
128
|
+
if (!isNonInteractive() && process.stderr.isTTY) {
|
|
129
|
+
const handle = yield* ChildProcess.make(nodeExecPath, args, {
|
|
130
|
+
...commandOptions,
|
|
131
|
+
stdin: "inherit",
|
|
132
|
+
stdout: "inherit",
|
|
133
|
+
stderr: "inherit",
|
|
134
|
+
}).pipe(Effect.mapError((cause) => new Error(`drizzle-kit generate failed: ${String(cause)}`)));
|
|
135
|
+
const exitCode = yield* handle.exitCode;
|
|
136
|
+
if (exitCode !== 0) {
|
|
137
|
+
return yield* Effect.fail(new Error(`drizzle-kit generate failed with exit ${exitCode}`));
|
|
138
|
+
}
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const result = yield* exec(ChildProcess.make(nodeExecPath, args, commandOptions)).pipe(Effect.mapError((cause) => new Error(`drizzle-kit generate failed: ${String(cause)}`)));
|
|
142
|
+
if (result.exitCode === 0)
|
|
143
|
+
return;
|
|
144
|
+
// Since drizzle-kit 1.0.0-rc.4 the non-interactive CLI refuses
|
|
145
|
+
// ambiguous decisions (rename-vs-create, data-loss confirmation)
|
|
146
|
+
// with a `missing_hints` report on exit 2. These are deliberate
|
|
147
|
+
// safety prompts — the generated SQL is applied to the real
|
|
148
|
+
// database later in the same deploy — so we never answer them
|
|
149
|
+
// automatically. Ask the user to decide.
|
|
150
|
+
if (result.exitCode === 2) {
|
|
151
|
+
return yield* Effect.fail(new Error([
|
|
152
|
+
`drizzle-kit needs a decision for ${props.schema} that cannot be made non-interactively (rename vs create, or a change that loses data):`,
|
|
153
|
+
"",
|
|
154
|
+
result.stdout.trim(),
|
|
155
|
+
"",
|
|
156
|
+
"To resolve, generate the migration yourself and commit it:",
|
|
157
|
+
` npx drizzle-kit generate --dialect ${dialect === "postgres" ? "postgresql" : dialect} --schema ${props.schema} --out ${props.out ?? "./migrations"}`,
|
|
158
|
+
"then re-run the deploy (the schema resource will see no drift and apply the committed migration).",
|
|
159
|
+
"Alternatively, run the deploy in a terminal to answer drizzle-kit's prompts interactively.",
|
|
160
|
+
].join("\n")));
|
|
161
|
+
}
|
|
162
|
+
return yield* Effect.fail(new Error(`drizzle-kit generate failed: ${result.stdout}\n${result.stderr}`));
|
|
163
|
+
});
|
|
164
|
+
// List `<ts>_*` migration directories under `out`, sorted by numeric
|
|
165
|
+
// prefix. Returns an empty array if `out` doesn't exist.
|
|
166
|
+
const listMigrationDirs = (out) => Effect.gen(function* () {
|
|
167
|
+
const exists = yield* fs.exists(out);
|
|
168
|
+
if (!exists)
|
|
169
|
+
return [];
|
|
170
|
+
const entries = yield* fs.readDirectory(out);
|
|
171
|
+
return entries.filter((name) => /^\d+_/.test(name)).sort();
|
|
172
|
+
});
|
|
173
|
+
// The latest snapshot is the head of the `prevIds` chain — the one no
|
|
174
|
+
// other snapshot points back to. Directory-name order alone is not
|
|
175
|
+
// enough: two migrations generated within the same second share the
|
|
176
|
+
// timestamp prefix, and the random name suffix then decides the sort.
|
|
177
|
+
const readLatestSnapshot = (out) => Effect.gen(function* () {
|
|
178
|
+
const dirs = yield* listMigrationDirs(out);
|
|
179
|
+
const entries = [];
|
|
180
|
+
for (const dir of dirs) {
|
|
181
|
+
const snapshotPath = path.join(out, dir, "snapshot.json");
|
|
182
|
+
const exists = yield* fs.exists(snapshotPath);
|
|
183
|
+
if (!exists)
|
|
184
|
+
continue;
|
|
185
|
+
const text = yield* fs.readFileString(snapshotPath);
|
|
186
|
+
entries.push({
|
|
187
|
+
snapshot: JSON.parse(text),
|
|
188
|
+
hash: sha(text),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (entries.length === 0)
|
|
192
|
+
return undefined;
|
|
193
|
+
const referenced = new Set(entries.flatMap((entry) => entry.snapshot.prevIds ?? []));
|
|
194
|
+
const head = entries.find((entry) => entry.snapshot.id !== undefined && !referenced.has(entry.snapshot.id));
|
|
195
|
+
// Fall back to name order for snapshots without id/prevIds chains.
|
|
196
|
+
return head ?? entries[entries.length - 1];
|
|
197
|
+
});
|
|
198
|
+
const detectDriftWithCli = (props) => Effect.gen(function* () {
|
|
199
|
+
const out = resolveOut(props);
|
|
200
|
+
const tmpOut = yield* fs.makeTempDirectory({
|
|
201
|
+
prefix: "alchemy-drizzle-generate-",
|
|
202
|
+
});
|
|
203
|
+
return yield* Effect.gen(function* () {
|
|
204
|
+
const outExists = yield* fs.exists(out);
|
|
205
|
+
if (outExists)
|
|
206
|
+
yield* copyDirectory(out, tmpOut);
|
|
207
|
+
const before = yield* listMigrationDirs(tmpOut);
|
|
208
|
+
yield* runDrizzleGenerate(props, tmpOut);
|
|
209
|
+
const after = yield* listMigrationDirs(tmpOut);
|
|
210
|
+
const latest = yield* readLatestSnapshot(tmpOut);
|
|
211
|
+
const changed = after.some((dir) => !before.includes(dir));
|
|
212
|
+
const prevEntry = outExists ? yield* readLatestSnapshot(out) : undefined;
|
|
213
|
+
return {
|
|
214
|
+
mode: "cli",
|
|
215
|
+
out,
|
|
216
|
+
cur: latest?.snapshot,
|
|
217
|
+
prevEntry,
|
|
218
|
+
changed,
|
|
219
|
+
};
|
|
220
|
+
}).pipe(Effect.ensuring(fs.remove(tmpOut, { recursive: true }).pipe(Effect.ignore)));
|
|
221
|
+
});
|
|
222
|
+
/**
|
|
223
|
+
* Run drizzle-kit's diff against the latest stored snapshot and
|
|
224
|
+
* return whether any SQL statements would be emitted. Used by both
|
|
225
|
+
* `diff` (to decide whether the resource actually needs an update)
|
|
226
|
+
* and `regenerate` (to decide whether to write a new migration dir).
|
|
227
|
+
*/
|
|
228
|
+
const detectDrift = (props) => Effect.gen(function* () {
|
|
229
|
+
const out = resolveOut(props);
|
|
230
|
+
const dialect = props.dialect ?? "postgres";
|
|
231
|
+
const kit = yield* loadKit(dialect);
|
|
232
|
+
if (!kit.generateDrizzleJson || !kit.generateMigration) {
|
|
233
|
+
return yield* detectDriftWithCli(props);
|
|
234
|
+
}
|
|
235
|
+
const generateDrizzleJson = kit.generateDrizzleJson;
|
|
236
|
+
const generateMigration = kit.generateMigration;
|
|
237
|
+
const schemaModule = yield* loadSchemaModule(props);
|
|
238
|
+
const prevEntry = yield* readLatestSnapshot(out);
|
|
239
|
+
const cur = yield* Effect.tryPromise({
|
|
240
|
+
try: () => generateDrizzleJson(schemaModule, prevEntry?.snapshot.id),
|
|
241
|
+
catch: (cause) => new Error(`drizzle-kit generateDrizzleJson failed: ${cause}`),
|
|
242
|
+
});
|
|
243
|
+
// For the initial migration, drizzle-kit needs an *empty* snapshot
|
|
244
|
+
// produced by `generateDrizzleJson({})`, not a bare `{}` — the
|
|
245
|
+
// snapshot has internal fields (`ddl`, etc.) that the differ reads.
|
|
246
|
+
const prev = prevEntry?.snapshot ??
|
|
247
|
+
(yield* Effect.tryPromise({
|
|
248
|
+
try: () => generateDrizzleJson({}),
|
|
249
|
+
catch: (cause) => new Error(`drizzle-kit generateDrizzleJson (empty baseline) failed: ${cause}`),
|
|
250
|
+
}));
|
|
251
|
+
const sqlStatements = yield* Effect.tryPromise({
|
|
252
|
+
try: () => generateMigration(prev, cur),
|
|
253
|
+
catch: (cause) => new Error(`drizzle-kit generateMigration failed: ${cause}`),
|
|
254
|
+
});
|
|
255
|
+
return {
|
|
256
|
+
mode: "programmatic",
|
|
257
|
+
out,
|
|
258
|
+
cur,
|
|
259
|
+
prevEntry,
|
|
260
|
+
sqlStatements,
|
|
261
|
+
};
|
|
262
|
+
}).pipe(Artifacts.cached("detectDrift"));
|
|
263
|
+
/**
|
|
264
|
+
* Generate a new migration directory if the schema has drifted from
|
|
265
|
+
* the latest snapshot. Returns the new state regardless.
|
|
266
|
+
*/
|
|
267
|
+
const regenerate = (props) => Effect.gen(function* () {
|
|
268
|
+
const drift = yield* detectDrift(props);
|
|
269
|
+
if (drift.mode === "cli") {
|
|
270
|
+
if (drift.changed) {
|
|
271
|
+
yield* runDrizzleGenerate(props, drift.out);
|
|
272
|
+
}
|
|
273
|
+
const migrations = yield* listMigrationDirs(drift.out);
|
|
274
|
+
const latest = yield* readLatestSnapshot(drift.out);
|
|
275
|
+
const snapshotHash = latest?.hash ?? sha(JSON.stringify(drift.cur));
|
|
276
|
+
return {
|
|
277
|
+
out: relativeOut(drift.out),
|
|
278
|
+
snapshotHash,
|
|
279
|
+
migrations,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
const { out, cur, sqlStatements } = drift;
|
|
283
|
+
if (sqlStatements.length > 0) {
|
|
284
|
+
yield* fs.makeDirectory(out, { recursive: true });
|
|
285
|
+
const dirName = `${tsStamp()}_migration`;
|
|
286
|
+
const dirPath = path.join(out, dirName);
|
|
287
|
+
yield* fs.makeDirectory(dirPath, { recursive: true });
|
|
288
|
+
const sql = sqlStatements.join("\n--> statement-breakpoint\n") + "\n";
|
|
289
|
+
yield* fs.writeFileString(path.join(dirPath, "migration.sql"), sql);
|
|
290
|
+
yield* fs.writeFileString(path.join(dirPath, "snapshot.json"), JSON.stringify(cur, null, 2));
|
|
291
|
+
}
|
|
292
|
+
const migrations = yield* listMigrationDirs(out);
|
|
293
|
+
const latest = yield* readLatestSnapshot(out);
|
|
294
|
+
const snapshotHash = latest?.hash ?? sha(JSON.stringify(cur));
|
|
295
|
+
return {
|
|
296
|
+
out: relativeOut(out),
|
|
297
|
+
snapshotHash,
|
|
298
|
+
migrations,
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
return {
|
|
302
|
+
// Non-listable: a Drizzle.Schema is a local build artifact (generated
|
|
303
|
+
// migration SQL under `out`, a path supplied entirely by props with no
|
|
304
|
+
// account/store to enumerate). There is no remote enumeration API, so
|
|
305
|
+
// there is nothing to discover out-of-band.
|
|
306
|
+
list: () => Effect.succeed([]),
|
|
307
|
+
diff: Effect.fn(function* ({ news, output }) {
|
|
308
|
+
if (!isResolved(news))
|
|
309
|
+
return undefined;
|
|
310
|
+
if (!output)
|
|
311
|
+
return undefined;
|
|
312
|
+
// Only flag an update when drizzle-kit would emit new SQL —
|
|
313
|
+
// otherwise downstream resources (e.g. Neon.Branch) would see
|
|
314
|
+
// `schema.out` as an unresolved Output during plan and cascade
|
|
315
|
+
// into spurious updates of their own.
|
|
316
|
+
const drift = yield* detectDrift(news);
|
|
317
|
+
const changed = drift.mode === "cli" ? drift.changed : drift.sqlStatements.length > 0;
|
|
318
|
+
// Originally `output.out` was an absolute path, which is not portable.
|
|
319
|
+
// So, we trigger an update to migrate existing resources to the
|
|
320
|
+
// canonical (cwd-relative) form. This is safe because `regenerate`
|
|
321
|
+
// is idempotent. Compare against the canonical form rather than
|
|
322
|
+
// testing `isAbsolute`: on Windows a cross-drive `out` can never be
|
|
323
|
+
// relativized, so its canonical form IS absolute and an isAbsolute
|
|
324
|
+
// check would flag an update on every deploy.
|
|
325
|
+
return changed || output.out !== relativeOut(resolveOut(news))
|
|
326
|
+
? { action: "update" }
|
|
327
|
+
: undefined;
|
|
328
|
+
}),
|
|
329
|
+
read: Effect.fn(function* ({ olds, output }) {
|
|
330
|
+
if (!output)
|
|
331
|
+
return undefined;
|
|
332
|
+
const out = resolveOut(olds ?? {});
|
|
333
|
+
const exists = yield* fs.exists(out);
|
|
334
|
+
if (!exists)
|
|
335
|
+
return undefined;
|
|
336
|
+
const latest = yield* readLatestSnapshot(out);
|
|
337
|
+
const migrations = yield* listMigrationDirs(out);
|
|
338
|
+
return {
|
|
339
|
+
out: relativeOut(out),
|
|
340
|
+
snapshotHash: latest?.hash ?? output.snapshotHash,
|
|
341
|
+
migrations,
|
|
342
|
+
};
|
|
343
|
+
}),
|
|
344
|
+
reconcile: Effect.fn(function* ({ news, output, session }) {
|
|
345
|
+
yield* session.note(`${output ? "Regenerating" : "Generating"} drizzle migrations for ${news.schema}`);
|
|
346
|
+
return yield* regenerate(news);
|
|
347
|
+
}),
|
|
348
|
+
delete: Effect.fn(function* () {
|
|
349
|
+
// Migrations are typically checked in; do not delete on resource
|
|
350
|
+
// teardown.
|
|
351
|
+
}),
|
|
352
|
+
};
|
|
353
|
+
}));
|
|
354
|
+
const copyDirectory = (from, to) => Effect.gen(function* () {
|
|
355
|
+
const path = yield* Path.Path;
|
|
356
|
+
const fs = yield* FileSystem.FileSystem;
|
|
357
|
+
yield* fs.makeDirectory(to, { recursive: true });
|
|
358
|
+
const entries = yield* fs.readDirectory(from);
|
|
359
|
+
for (const entry of entries) {
|
|
360
|
+
const source = path.join(from, entry);
|
|
361
|
+
const target = path.join(to, entry);
|
|
362
|
+
const stat = yield* fs.stat(source);
|
|
363
|
+
if (stat.type === "Directory") {
|
|
364
|
+
yield* copyDirectory(source, target);
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
const contents = yield* fs.readFile(source);
|
|
368
|
+
yield* fs.writeFile(target, contents);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
//# sourceMappingURL=Schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Schema.js","sourceRoot":"","sources":["../src/Schema.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,mB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CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAMxB,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,8BAA8B,EAC9B,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./D1.js";
|
|
2
|
+
// The tagged errors drizzle's effect drivers fail with — re-exported so
|
|
3
|
+
// consumers can reference them without reaching into drizzle-orm
|
|
4
|
+
// internals. (`Effect.catchTag` needs only the tag string; these are for
|
|
5
|
+
// instanceof checks, schemas, and annotations.)
|
|
6
|
+
export { EffectDrizzleError, EffectDrizzleQueryError, EffectTransactionRollbackError, MigratorInitError, } from "drizzle-orm/effect-core";
|
|
7
|
+
export * from "./Providers.js";
|
|
8
|
+
export * from "./Schema.js";
|
|
9
|
+
// MySQL and Postgres are deliberately NOT re-exported here: their drivers
|
|
10
|
+
// (`@effect/sql-mysql2`/`mysql2`, `@effect/sql-pg`/`pg`) are optional peer
|
|
11
|
+
// dependencies, and keeping them out of the barrel keeps them out of every
|
|
12
|
+
// non-user's module graph. Import them via their subpaths instead:
|
|
13
|
+
// `@alchemy.run/drizzle/MySQL`, `@alchemy.run/drizzle/Postgres`.
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,wEAAwE;AACxE,iEAAiE;AACjE,yEAAyE;AACzE,gDAAgD;AAChD,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,8BAA8B,EAC9B,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,mEAAmE;AACnE,iEAAiE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alchemy.run/drizzle",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "2.0.0-beta.84",
|
|
4
4
|
"description": "Drizzle ORM integration for Alchemy: schemas, migrations and Effect SQL clients.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"alchemy",
|
|
@@ -9,12 +9,87 @@
|
|
|
9
9
|
"infrastructure-as-code",
|
|
10
10
|
"sql"
|
|
11
11
|
],
|
|
12
|
+
"homepage": "https://alchemy.run",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/alchemy-run/alchemy/issues"
|
|
15
|
+
},
|
|
12
16
|
"license": "Apache-2.0",
|
|
13
17
|
"author": "Sam Goodwin <sam@alchemy.run>",
|
|
14
|
-
"homepage": "https://alchemy.run",
|
|
15
18
|
"repository": {
|
|
16
19
|
"type": "git",
|
|
17
20
|
"url": "git+https://github.com/alchemy-run/alchemy.git",
|
|
18
21
|
"directory": "packages/drizzle"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"lib",
|
|
25
|
+
"src"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./lib/index.d.ts",
|
|
32
|
+
"bun": "./src/index.ts",
|
|
33
|
+
"worker": "./src/index.ts",
|
|
34
|
+
"default": "./lib/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./*": {
|
|
37
|
+
"types": "./lib/*.d.ts",
|
|
38
|
+
"bun": "./src/*.ts",
|
|
39
|
+
"worker": "./src/*.ts",
|
|
40
|
+
"default": "./lib/*.js"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@alchemy.run/sql": "2.0.0-beta.84",
|
|
49
|
+
"@effect/sql-d1": "^4.0.5",
|
|
50
|
+
"@effect/sql-sqlite-do": "^4.0.5"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@alchemy.run/cloudflare": "2.0.0-beta.84",
|
|
54
|
+
"@cloudflare/workers-types": "5.20261012.1",
|
|
55
|
+
"@effect/sql-libsql": "^4.0.5",
|
|
56
|
+
"@effect/sql-mysql2": "^4.0.5",
|
|
57
|
+
"@effect/sql-pg": "^4.0.5",
|
|
58
|
+
"@types/bun": "1.4.3",
|
|
59
|
+
"alchemy": "2.0.0-beta.84",
|
|
60
|
+
"drizzle-orm": "1.0.0-rc.5-ab785fc",
|
|
61
|
+
"effect": "^4.0.5",
|
|
62
|
+
"typescript": "^7.0.2"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@alchemy.run/cloudflare": "2.0.0-beta.84",
|
|
66
|
+
"@effect/sql-libsql": "^4.0.5",
|
|
67
|
+
"@effect/sql-mysql2": "^4.0.5",
|
|
68
|
+
"@effect/sql-pg": "^4.0.5",
|
|
69
|
+
"alchemy": "2.0.0-beta.84",
|
|
70
|
+
"drizzle-kit": "1.0.0-rc.5-ab785fc",
|
|
71
|
+
"drizzle-orm": "1.0.0-rc.5-ab785fc",
|
|
72
|
+
"effect": "^4.0.5"
|
|
73
|
+
},
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"@alchemy.run/cloudflare": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"@effect/sql-libsql": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"@effect/sql-mysql2": {
|
|
82
|
+
"optional": true
|
|
83
|
+
},
|
|
84
|
+
"@effect/sql-pg": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"drizzle-kit": {
|
|
88
|
+
"optional": true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"scripts": {
|
|
92
|
+
"build": "pnpm -r --filter \"{.}...\" run build:package",
|
|
93
|
+
"build:package": "node scripts/build.ts"
|
|
19
94
|
}
|
|
20
|
-
}
|
|
95
|
+
}
|