Add models and migrations
This commit is contained in:
parent
2dded1b585
commit
c759f3617e
2 changed files with 55 additions and 13 deletions
|
|
@ -2,10 +2,31 @@ async def m001_initial(db):
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS TwitchAlerts (
|
CREATE TABLE IF NOT EXISTS Services (
|
||||||
id TEXT PRIMARY KEY,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
twitchuser TEXT NOT NULL,
|
||||||
|
client_id TEXT NOT NULL,
|
||||||
|
client_secret TEXT NOT NULL,
|
||||||
wallet TEXT NOT NULL,
|
wallet TEXT NOT NULL,
|
||||||
time TIMESTAMP NOT NULL DEFAULT (strftime('%s', 'now'))
|
onchain TEXT,
|
||||||
|
servicename TEXT NOT NULL,
|
||||||
|
authenticated BOOLEAN NOT NULL,
|
||||||
|
token TEXT
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
await db.execute(
|
||||||
|
"""
|
||||||
|
CREATE TABLE IF NOT EXISTS Donations (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
cur_code TEXT NOT NULL,
|
||||||
|
sats INT NOT NULL,
|
||||||
|
amount FLOAT NOT NULL,
|
||||||
|
service INTEGER NOT NULL,
|
||||||
|
posted BOOLEAN NOT NULL,
|
||||||
|
FOREIGN KEY(service) REFERENCES Services(id)
|
||||||
|
);
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,32 @@
|
||||||
# from sqlite3 import Row
|
from sqlite3 import Row
|
||||||
# from typing import NamedTuple
|
from typing import NamedTuple, Optional
|
||||||
|
|
||||||
|
|
||||||
# class Example(NamedTuple):
|
class Donations(NamedTuple):
|
||||||
# id: str
|
id: str
|
||||||
# wallet: str
|
name: str
|
||||||
#
|
cur_code: str
|
||||||
# @classmethod
|
sats: int
|
||||||
# def from_row(cls, row: Row) -> "Example":
|
amount: float
|
||||||
# return cls(**dict(row))
|
service: int
|
||||||
|
posted: bool
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_row(cls, row: Row) -> "Donations":
|
||||||
|
return cls(**dict(row))
|
||||||
|
|
||||||
|
|
||||||
|
class Services(NamedTuple):
|
||||||
|
id: int
|
||||||
|
twitchuser: str
|
||||||
|
client_id: str
|
||||||
|
client_secret: str
|
||||||
|
wallet: str
|
||||||
|
onchain: str
|
||||||
|
servicename: str
|
||||||
|
authenticated: bool
|
||||||
|
token: Optional[int]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_row(cls, row: Row) -> "Services":
|
||||||
|
return cls(**dict(row))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue