Store set types

This commit is contained in:
Correl Roush 2024-02-26 18:07:27 -05:00
parent ed7ac88db0
commit 4a0fc6e539
2 changed files with 10 additions and 4 deletions

View file

@ -0,0 +1,4 @@
ALTER TABLE "sets"
ADD COLUMN IF NOT EXISTS "set_type" TEXT NOT NULL DEFAULT 'core';
CREATE INDEX IF NOT EXISTS "sets_type" ON "sets" ("set_type");

View file

@ -335,14 +335,16 @@ async def store_price(
)
async def store_set(db: psycopg.AsyncCursor, set_code: str, name: str) -> None:
async def store_set(
db: psycopg.AsyncCursor, set_code: str, set_type: str, name: str
) -> None:
await db.execute(
"""
INSERT INTO "sets" ("set_code", "name")
VALUES (%(set_code)s, %(name)s)
INSERT INTO "sets" ("set_code", "set_type", "name")
VALUES (%(set_code)s, %(set_type)s, %(name)s)
ON CONFLICT ("set_code") DO NOTHING
""",
{"set_code": set_code, "name": name},
{"set_code": set_code, "set_type": set_type, "name": name},
)