keryx 0.10.2 → 0.10.4

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.
@@ -3,6 +3,7 @@ import { type Config as DrizzleMigrateConfig } from "drizzle-kit";
3
3
  import { DefaultLogger, type LogWriter, sql } from "drizzle-orm";
4
4
  import { drizzle } from "drizzle-orm/node-postgres";
5
5
  import { migrate } from "drizzle-orm/node-postgres/migrator";
6
+ import fs from "node:fs";
6
7
  import { unlink } from "node:fs/promises";
7
8
  import path from "path";
8
9
  import { Pool } from "pg";
@@ -68,9 +69,18 @@ export class DB extends Initializer {
68
69
 
69
70
  if (config.database.autoMigrate) {
70
71
  try {
71
- await migrate(api.db.db, {
72
- migrationsFolder: path.join(api.rootDir, "drizzle"),
73
- });
72
+ const migrationsFolder = path.join(api.rootDir, "drizzle");
73
+ const journalPath = path.join(
74
+ migrationsFolder,
75
+ "meta",
76
+ "_journal.json",
77
+ );
78
+ if (!fs.existsSync(journalPath)) {
79
+ fs.mkdirSync(path.dirname(journalPath), { recursive: true });
80
+ fs.writeFileSync(journalPath, JSON.stringify({ entries: [] }));
81
+ logger.info("created empty drizzle migrations journal");
82
+ }
83
+ await migrate(api.db.db, { migrationsFolder });
74
84
  logger.info("database migrated successfully");
75
85
  } catch (e) {
76
86
  throw new TypedError({
@@ -103,7 +113,7 @@ export class DB extends Initializer {
103
113
  async generateMigrations() {
104
114
  const migrationConfig = {
105
115
  dialect: "postgresql",
106
- schema: path.join("models", "*"),
116
+ schema: path.join("schema", "*"),
107
117
  dbCredentials: {
108
118
  url: config.database.connectionString,
109
119
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keryx",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,3 +1,3 @@
1
1
  node_modules/
2
2
  .env
3
- drizzle/
3
+ drizzle/config.tmp.ts
package/util/cli.ts CHANGED
@@ -62,14 +62,15 @@ export async function buildProgram(opts: {
62
62
  const files = await scaffoldProject(projectName, targetDir, options);
63
63
  files.forEach((f) => console.log(` ${f}`));
64
64
 
65
- console.log(`
66
- Done! To get started:
67
-
68
- cd ${projectName}
69
- cp .env.example .env
70
- bun install
71
- bun dev
72
- `);
65
+ const steps = [` cd ${projectName}`, ` cp .env.example .env`];
66
+ if (options.includeDb) {
67
+ steps.push(` createdb ${projectName}`);
68
+ steps.push(` createdb ${projectName}-test`);
69
+ }
70
+ steps.push(` bun install`);
71
+ steps.push(` bun dev`);
72
+
73
+ console.log(`\nDone! To get started:\n\n${steps.join("\n")}\n`);
73
74
  process.exit(0);
74
75
  });
75
76
 
package/util/scaffold.ts CHANGED
@@ -291,7 +291,7 @@ export async function scaffoldProject(
291
291
  if (options.includeDb) {
292
292
  await writeTemplate("migrations.ts", "migrations.ts.mustache");
293
293
  await write("schema/.gitkeep", "");
294
- await write("drizzle/.gitkeep", "");
294
+ await write("drizzle/meta/_journal.json", JSON.stringify({ entries: [] }));
295
295
  }
296
296
 
297
297
  // --- Built-in actions (always included) ---