From b18b0f3c47e8dedd4df0c4a1670d58146fbd63fd Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Tue, 29 Oct 2024 15:27:34 +0200 Subject: [PATCH] chore: code clean-up --- crud.py | 2 +- migrations.py | 33 --------------------------------- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/crud.py b/crud.py index 73a33ad..a7b4491 100644 --- a/crud.py +++ b/crud.py @@ -305,7 +305,7 @@ async def delete_inferior_ranking(name: str, rank: int): async def create_settings(settings: Nip5Settings): - assert settings.owner_id, 'Missing owner ID.' + assert settings.owner_id, "Missing owner ID." await db.insert("nostrnip5.settings", settings) diff --git a/migrations.py b/migrations.py index 67b0d86..2532b70 100644 --- a/migrations.py +++ b/migrations.py @@ -103,36 +103,3 @@ async def m007_add_cost_extra_column_to_addresses(db: Database): "reimburse_amount REAL NOT NULL DEFAULT 0" ) - -async def m007_migrate_settings(db: Database): - - result = await db.execute("SELECT * FROM nostrnip5.settings") - settings = await result.mappings().all() - await db.execute("ALTER TABLE nostrnip5.settings RENAME TO settings_old") - await db.execute( - """ - CREATE TABLE nostrnip5.settings ( - owner_id TEXT PRIMARY KEY, - cloudflare_api_key TEXT, - lnaddress_api_admin_key TEXT, - lnaddress_api_endpoint TEXT, - ); - """ - ) - for raw_setting in settings: - owner_id = raw_setting["owner_id"] - setting = json.loads(raw_setting["settings"]) - await db.execute( - """ - INSERT INTO nostrnip5.settings ( owner_id, cloudflare_api_key, - lnaddress_api_admin_key, lnaddress_api_endpoint) - VALUES ( :owner_id, :cloudflare_api_key, - :lnaddress_api_admin_key, :lnaddress_api_endpoint) - """, - { - "owner_id": owner_id, - "cloudflare_api_key": setting.get("cloudflare_api_key"), - "lnaddress_api_admin_key": setting.get("lnaddress_api_admin_key"), - "lnaddress_api_endpoint": setting.get("lnaddress_api_endpoint"), - }, - )