Skip to content

Commit

Permalink
chore: code clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
motorina0 committed Oct 29, 2024
1 parent e57c224 commit b18b0f3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
2 changes: 1 addition & 1 deletion crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
33 changes: 0 additions & 33 deletions migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
},
)

0 comments on commit b18b0f3

Please sign in to comment.