forked from lnbits/tpos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrations.py
108 lines (96 loc) · 2.43 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
async def m001_initial(db):
"""
Initial tposs table.
"""
await db.execute(
"""
CREATE TABLE tpos.tposs (
id TEXT PRIMARY KEY,
wallet TEXT NOT NULL,
name TEXT NOT NULL,
currency TEXT NOT NULL
);
"""
)
async def m002_addtip_wallet(db):
"""
Add tips to tposs table
"""
await db.execute(
"""
ALTER TABLE tpos.tposs ADD tip_wallet TEXT NULL;
"""
)
async def m003_addtip_options(db):
"""
Add tips to tposs table
"""
await db.execute(
"""
ALTER TABLE tpos.tposs ADD tip_options TEXT NULL;
"""
)
async def m004_addwithdrawlimit(db):
rows = [list(row) for row in await db.fetchall("SELECT * FROM tpos.tposs")]
await db.execute(
"""
CREATE TABLE tpos.pos (
id TEXT PRIMARY KEY,
wallet TEXT NOT NULL,
name TEXT NOT NULL,
currency TEXT NOT NULL,
tip_wallet TEXT NULL,
tip_options TEXT NULL,
withdrawlimit INTEGER DEFAULT 0,
withdrawpin INTEGER DEFAULT 878787,
withdrawamt INTEGER DEFAULT 0,
withdrawtime INTEGER NOT NULL DEFAULT 0,
withdrawbtwn INTEGER NOT NULL DEFAULT 10
);
"""
)
for row in rows:
await db.execute(
"""
INSERT INTO tpos.pos (
id,
wallet,
name,
currency,
tip_wallet,
tip_options
)
VALUES (?, ?, ?, ?, ?, ?)
""",
(row[0], row[1], row[2], row[3], row[4], row[5]),
)
await db.execute("DROP TABLE tpos.tposs")
async def m005_initial(db):
"""
Initial withdraws table.
"""
await db.execute(
f"""
CREATE TABLE tpos.withdraws (
id TEXT PRIMARY KEY,
tpos_id TEXT NOT NULL,
amount int,
claimed BOOLEAN DEFAULT false
);
"""
)
async def m006_items(db):
"""
Add items to tpos table for storing various items (JSON format)
See `Item` class in models.
"""
await db.execute(
"""
ALTER TABLE tpos.pos ADD items TEXT DEFAULT '[]';
"""
)
async def m007_atm_premium(db):
"""
Add a premium % to ATM withdraws
"""
await db.execute("ALTER TABLE tpos.pos ADD COLUMN withdrawpremium FLOAT;")