forked from lnbits/nostrrelay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrations.py
64 lines (60 loc) · 1.63 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
async def m001_initial(db):
"""
Initial nostrrelays tables.
"""
await db.execute(
"""
CREATE TABLE nostrrelay.relays (
user_id TEXT NOT NULL,
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
description TEXT,
pubkey TEXT,
contact TEXT,
active BOOLEAN DEFAULT false,
meta TEXT NOT NULL DEFAULT '{}'
);
"""
)
await db.execute(
f"""
CREATE TABLE nostrrelay.events (
relay_id TEXT NOT NULL,
deleted BOOLEAN DEFAULT false,
publisher TEXT NOT NULL,
id TEXT NOT NULL,
pubkey TEXT NOT NULL,
created_at {db.big_int} NOT NULL,
kind INT NOT NULL,
content TEXT NOT NULL,
sig TEXT NOT NULL,
size {db.big_int} DEFAULT 0,
PRIMARY KEY (relay_id, id)
);
"""
)
await db.execute(
"""
CREATE TABLE nostrrelay.event_tags (
relay_id TEXT NOT NULL,
event_id TEXT NOT NULL,
name TEXT NOT NULL,
value TEXT NOT NULL,
extra TEXT
);
"""
)
await db.execute(
f"""
CREATE TABLE nostrrelay.accounts (
relay_id TEXT NOT NULL,
pubkey TEXT NOT NULL,
sats {db.big_int} DEFAULT 0,
storage {db.big_int} DEFAULT 0,
paid_to_join BOOLEAN DEFAULT false,
allowed BOOLEAN DEFAULT false,
blocked BOOLEAN DEFAULT false,
PRIMARY KEY (relay_id, pubkey)
);
"""
)