mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-25 19:16:19 +00:00
arreglar migracion cli
This commit is contained in:
parent
cc0af3011a
commit
4669e6087f
3 changed files with 10 additions and 2 deletions
3
db-datos/migrate-cli.js
Normal file
3
db-datos/migrate-cli.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { getDb } from "./db.js";
|
||||
|
||||
getDb();
|
|
@ -2,12 +2,17 @@
|
|||
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
|
||||
import * as schema from "./schema.js";
|
||||
import { sql } from "drizzle-orm";
|
||||
import { existsSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
/**
|
||||
* @param {import("drizzle-orm/better-sqlite3").BetterSQLite3Database<schema>} db
|
||||
*/
|
||||
export function migrateDb(db) {
|
||||
migrate(db, { migrationsFolder: "node_modules/db-datos/drizzle" });
|
||||
let path = "drizzle/";
|
||||
if (!existsSync(join(path, "meta/_journal.json")))
|
||||
path = "node_modules/db-datos/drizzle";
|
||||
migrate(db, { migrationsFolder: path });
|
||||
db.run(sql`pragma journal_mode = WAL;`);
|
||||
db.run(sql`PRAGMA synchronous = NORMAL;`);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"main": "index.js",
|
||||
"scripts": {
|
||||
"generate": "drizzle-kit generate:sqlite",
|
||||
"migrate": "node db.js"
|
||||
"migrate": "node migrate-cli.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
|
Loading…
Reference in a new issue