mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-01-18 13:27:20 +01: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
|
||||
htmlcov
|
||||
Pipfile.lock
|
||||
|
||||
*.swo
|
||||
*.swp
|
||||
*.pyo
|
||||
*.pyc
|
||||
*.env
|
||||
venv
|
||||
|
||||
database.sqlite3
|
||||
|
@ -1,3 +1,4 @@
|
||||
import os
|
||||
import lnurl
|
||||
import requests
|
||||
import time
|
||||
@ -6,7 +7,7 @@ from flask import Flask, jsonify, render_template, request
|
||||
|
||||
from .db import Database
|
||||
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__)
|
||||
@ -19,6 +20,14 @@ def db_connect(db_path=DATABASE_PATH):
|
||||
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("/")
|
||||
def home():
|
||||
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…
Reference in New Issue
Block a user