@coffre/cli 0.1.1 → 0.1.2

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.
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1790930587507,
9
+ "tag": "0000_baseline",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,37 @@
1
+ import fs from "node:fs";
2
+ import crypto from "node:crypto";
3
+ //#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/migrator.js
4
+ function readMigrationFiles(config) {
5
+ const migrationFolderTo = config.migrationsFolder;
6
+ const migrationQueries = [];
7
+ const journalPath = `${migrationFolderTo}/meta/_journal.json`;
8
+ if (!fs.existsSync(journalPath)) throw new Error(`Can't find meta/_journal.json file`);
9
+ const journalAsString = fs.readFileSync(`${migrationFolderTo}/meta/_journal.json`).toString();
10
+ const journal = JSON.parse(journalAsString);
11
+ for (const journalEntry of journal.entries) {
12
+ const migrationPath = `${migrationFolderTo}/${journalEntry.tag}.sql`;
13
+ try {
14
+ const query = fs.readFileSync(`${migrationFolderTo}/${journalEntry.tag}.sql`).toString();
15
+ const result = query.split("--> statement-breakpoint").map((it) => {
16
+ return it;
17
+ });
18
+ migrationQueries.push({
19
+ sql: result,
20
+ bps: journalEntry.breakpoints,
21
+ folderMillis: journalEntry.when,
22
+ hash: crypto.createHash("sha256").update(query).digest("hex")
23
+ });
24
+ } catch {
25
+ throw new Error(`No file ${migrationPath} found in ${migrationFolderTo} folder`);
26
+ }
27
+ }
28
+ return migrationQueries;
29
+ }
30
+ //#endregion
31
+ //#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/node-postgres/migrator.js
32
+ async function migrate(db, config) {
33
+ const migrations = readMigrationFiles(config);
34
+ await db.dialect.migrate(migrations, db.session, config);
35
+ }
36
+ //#endregion
37
+ export { migrate };
@@ -0,0 +1,2 @@
1
+ import { a as NodePgSession, i as NodePgPreparedQuery, n as NodePgDriver, o as NodePgTransaction, r as drizzle, t as NodePgDatabase } from "./node-postgres-_y-EeSHQ.js";
2
+ export { NodePgDatabase, NodePgDriver, NodePgPreparedQuery, NodePgSession, NodePgTransaction, drizzle };