Filter and tokens update
This commit is contained in:
@@ -12,6 +12,12 @@ def conn():
|
||||
return c
|
||||
|
||||
|
||||
def _add_column(c, table, col, decl):
|
||||
cols = [r[1] for r in c.execute(f"PRAGMA table_info({table})").fetchall()]
|
||||
if col not in cols:
|
||||
c.execute(f"ALTER TABLE {table} ADD COLUMN {col} {decl}")
|
||||
|
||||
|
||||
def init():
|
||||
DB_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||
with conn() as c:
|
||||
@@ -26,13 +32,15 @@ def init():
|
||||
total INTEGER DEFAULT 0
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS cards (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
deck_slug TEXT NOT NULL REFERENCES decks(slug) ON DELETE CASCADE,
|
||||
name TEXT NOT NULL,
|
||||
position INTEGER NOT NULL,
|
||||
filename TEXT,
|
||||
price_usd REAL DEFAULT 0,
|
||||
fetch_status TEXT DEFAULT 'pending'
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
deck_slug TEXT NOT NULL REFERENCES decks(slug) ON DELETE CASCADE,
|
||||
name TEXT NOT NULL,
|
||||
position INTEGER NOT NULL,
|
||||
filename TEXT,
|
||||
back_filename TEXT,
|
||||
scry_url TEXT,
|
||||
price_usd REAL DEFAULT 0,
|
||||
fetch_status TEXT DEFAULT 'pending'
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS logs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -40,6 +48,8 @@ def init():
|
||||
line TEXT NOT NULL
|
||||
);
|
||||
""")
|
||||
_add_column(c, "cards", "back_filename", "TEXT")
|
||||
_add_column(c, "cards", "scry_url", "TEXT")
|
||||
|
||||
|
||||
def get_deck(slug: str):
|
||||
|
||||
Reference in New Issue
Block a user