actual/packages/loot-core/bin/get-db-schema

36 lines
782 B
Text
Raw Normal View History

2022-04-29 02:44:38 +00:00
#!/usr/bin/env ./cli-runner.js
process.env.LOOT_DATA_DIR = __dirname + '/../../../../data';
import * as sqlite from '../platform/server/sqlite';
import * as db from '../server/db';
import { getMessages } from '../server/sync';
let dbPath = process.argv[2];
let tables = [
'spreadsheet_cells',
'accounts',
'transactions',
'categories',
'category_groups',
'category_mapping',
'payees',
'payee_rules',
'payee_mapping'
];
async function init() {
db.setDatabase(sqlite.openDatabase(dbPath));
let schema = {};
for (let table of tables) {
let fields = await db.all(`PRAGMA table_info(${table})`);
schema[table] = {};
for (let field of fields) {
schema[table][field.name] = field.type.toLowerCase();
}
}
console.log(schema);
}
init();