readme and bootstrap
This commit is contained in:
parent
e8aeac48c5
commit
ede83f9050
@ -5,6 +5,34 @@ const databaseFile = "mytest.db"
|
|||||||
fs.readFile(databaseFile, (err, data) => {
|
fs.readFile(databaseFile, (err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
fs.openSync(databaseFile, 'w');
|
fs.openSync(databaseFile, 'w');
|
||||||
|
const db = require('better-sqlite3')(databaseFile);
|
||||||
|
// Bootstrap the db
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS accounts (
|
||||||
|
number integer NOT NULL,
|
||||||
|
name text NOT NULL,
|
||||||
|
qualifiedName text NOT NULL UNIQUE,
|
||||||
|
parentAccount text,
|
||||||
|
description text NOT NULL,
|
||||||
|
type TEXT NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS transactions (
|
||||||
|
transaction_id integer PRIMARY KEY,
|
||||||
|
postingDate text NOT NULL,
|
||||||
|
valueDate text,
|
||||||
|
title text NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS transaction_entries (
|
||||||
|
transaction_id int,
|
||||||
|
account_name text NOT NULL,
|
||||||
|
amount float,
|
||||||
|
label text,
|
||||||
|
FOREIGN KEY (transaction_id) REFERENCES transactions (transaction_id) FOREIGN KEY (account_name) REFERENCES accounts (qualifiedName) PRIMARY KEY (transaction_id, account_name)
|
||||||
|
);
|
||||||
|
`)
|
||||||
|
|
||||||
create_initial_accounts()
|
create_initial_accounts()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -42,32 +70,6 @@ function create_initial_accounts() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bootstrap the db
|
|
||||||
db.exec(`
|
|
||||||
CREATE TABLE IF NOT EXISTS accounts (
|
|
||||||
number integer NOT NULL,
|
|
||||||
name text NOT NULL,
|
|
||||||
qualifiedName text NOT NULL UNIQUE,
|
|
||||||
parentAccount text,
|
|
||||||
description text NOT NULL,
|
|
||||||
type TEXT NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS transactions (
|
|
||||||
transaction_id integer PRIMARY KEY,
|
|
||||||
postingDate text NOT NULL,
|
|
||||||
valueDate text,
|
|
||||||
title text NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS transaction_entries (
|
|
||||||
transaction_id int,
|
|
||||||
account_name text NOT NULL,
|
|
||||||
amount float,
|
|
||||||
label text,
|
|
||||||
FOREIGN KEY (transaction_id) REFERENCES transactions (transaction_id) FOREIGN KEY (account_name) REFERENCES accounts (qualifiedName) PRIMARY KEY (transaction_id, account_name)
|
|
||||||
);
|
|
||||||
`)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
readme.md
Normal file
2
readme.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Unser Backend + Frontend
|
||||||
|
Einfach starten mit `npm run run`. Database erstellt sich selber.
|
||||||
@ -1,2 +0,0 @@
|
|||||||
* TODO What is account.number?
|
|
||||||
id? wtf
|
|
||||||
Loading…
x
Reference in New Issue
Block a user