-
Notifications
You must be signed in to change notification settings - Fork 2
/
migrations.py
72 lines (64 loc) · 1.7 KB
/
migrations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import json
from lnbits.db import Database
async def m001_initial(db):
"""
Initial device table.
"""
await db.execute(
f"""
CREATE TABLE devicetimer.device (
id TEXT NOT NULL PRIMARY KEY,
key TEXT NOT NULL,
title TEXT NOT NULL,
wallet TEXT NOT NULL,
currency TEXT NOT NULL,
switches TEXT,
available_start TEXT DEFAULT '09:00',
available_stop TEXT DEFAULT '17:00',
timeout INT DEFAULT 30,
timestamp TIMESTAMP NOT NULL DEFAULT {db.timestamp_now}
);
"""
)
await db.execute(
f"""
CREATE TABLE devicetimer.payment (
id TEXT NOT NULL PRIMARY KEY,
deviceid TEXT NOT NULL,
switchid TEXT NOT NULL,
payhash TEXT,
payload TEXT NOT NULL,
sats {db.big_int},
timestamp TIMESTAMP NOT NULL DEFAULT {db.timestamp_now}
);
"""
)
async def m002_redux(db):
await db.execute(
f"""
ALTER TABLE devicetimer.device ADD COLUMN closed_url TEXT
"""
)
async def m003_redux(db):
await db.execute(
f"""
ALTER TABLE devicetimer.device ADD COLUMN wait_url TEXT
"""
)
async def m004_redux(db):
await db.execute(
f"""
ALTER TABLE devicetimer.device ADD COLUMN maxperday INT DEFAULT 0
"""
)
async def m005_redux(db):
await db.execute(
f"""
ALTER TABLE devicetimer.device ADD COLUMN timezone TEXT DEFAULT 'europe/amsterdam';
"""
)
await db.execute(
f"""
UPDATE devicetimer.device SET timezone='europe/amsterdam'
"""
)