mirror of
https://github.com/lnbits/lnbits.git
synced 2025-06-15 11:21:44 +02:00
move schema to sqlfile, create on init.
This commit is contained in:
parent
978854fc72
commit
7097d01f9e
3
.gitignore
vendored
3
.gitignore
vendored
@ -13,9 +13,12 @@ __pycache__
|
|||||||
.pytest_cache
|
.pytest_cache
|
||||||
htmlcov
|
htmlcov
|
||||||
Pipfile.lock
|
Pipfile.lock
|
||||||
|
|
||||||
*.swo
|
*.swo
|
||||||
*.swp
|
*.swp
|
||||||
*.pyo
|
*.pyo
|
||||||
*.pyc
|
*.pyc
|
||||||
*.env
|
*.env
|
||||||
venv
|
venv
|
||||||
|
|
||||||
|
database.sqlite3
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import lnurl
|
import lnurl
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
@ -6,7 +7,7 @@ from flask import Flask, jsonify, render_template, request
|
|||||||
|
|
||||||
from .db import Database
|
from .db import Database
|
||||||
from .helpers import encrypt
|
from .helpers import encrypt
|
||||||
from .settings import INVOICE_KEY, ADMIN_KEY, API_ENDPOINT, DATABASE_PATH
|
from .settings import INVOICE_KEY, ADMIN_KEY, API_ENDPOINT, DATABASE_PATH, LNBITS_PATH
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@ -19,6 +20,14 @@ def db_connect(db_path=DATABASE_PATH):
|
|||||||
return con
|
return con
|
||||||
|
|
||||||
|
|
||||||
|
@app.before_first_request
|
||||||
|
def init():
|
||||||
|
with Database() as db:
|
||||||
|
with open(os.path.join(LNBITS_PATH, "data/schema.sql")) as schemafile:
|
||||||
|
for stmt in schemafile.read().split("\n\n"):
|
||||||
|
db.execute(stmt, [])
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def home():
|
def home():
|
||||||
return render_template("index.html")
|
return render_template("index.html")
|
||||||
|
Binary file not shown.
22
LNbits/data/schema.sql
Normal file
22
LNbits/data/schema.sql
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS accounts (
|
||||||
|
userhash text PRIMARY KEY,
|
||||||
|
email text,
|
||||||
|
pass text
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS wallets (
|
||||||
|
hash text PRIMARY KEY,
|
||||||
|
name text NOT NULL,
|
||||||
|
user text NOT NULL,
|
||||||
|
adminkey text NOT NULL,
|
||||||
|
inkey text
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS apipayments (
|
||||||
|
payhash text PRIMARY KEY,
|
||||||
|
amount integer NOT NULL,
|
||||||
|
fee integer NOT NULL,
|
||||||
|
wallet text NOT NULL,
|
||||||
|
pending boolean NOT NULL,
|
||||||
|
memo text
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user