Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add migrations
Browse files Browse the repository at this point in the history
dni committed Sep 25, 2024
1 parent ce369c9 commit 5e25d80
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions migrations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
async def m001_initial(db):
from lnbits.db import Database


async def m001_initial(db: Database):
"""
Initial tposs table.
"""
@@ -14,7 +17,7 @@ async def m001_initial(db):
)


async def m002_addtip_wallet(db):
async def m002_addtip_wallet(db: Database):
"""
Add tips to tposs table
"""
@@ -25,7 +28,7 @@ async def m002_addtip_wallet(db):
)


async def m003_addtip_options(db):
async def m003_addtip_options(db: Database):
"""
Add tips to tposs table
"""
@@ -36,8 +39,7 @@ async def m003_addtip_options(db):
)


async def m004_addwithdrawlimit(db):
rows = [list(row) for row in await db.fetchall("SELECT * FROM tpos.tposs")]
async def m004_addwithdrawlimit(db: Database):
await db.execute(
"""
CREATE TABLE tpos.pos (
@@ -55,6 +57,7 @@ async def m004_addwithdrawlimit(db):
);
"""
)
rows = await db.fetchall("SELECT * FROM tpos.tposs")
for row in rows:
await db.execute(
"""
@@ -66,14 +69,21 @@ async def m004_addwithdrawlimit(db):
tip_wallet,
tip_options
)
VALUES (?, ?, ?, ?, ?, ?)
VALUES (:id, :wallet, :name, :currency, :tip_wallet, :tip_options)
""",
(row[0], row[1], row[2], row[3], row[4], row[5]),
{
"id": row["id"],
"wallet": row["wallet"],
"name": row["name"],
"currency": row["currency"],
"tip_wallet": row["tip_wallet"],
"tip_options": row["tip_options"],
},
)
await db.execute("DROP TABLE tpos.tposs")


async def m005_initial(db):
async def m005_initial(db: Database):
"""
Initial withdraws table.
"""
@@ -89,7 +99,7 @@ async def m005_initial(db):
)


async def m006_items(db):
async def m006_items(db: Database):
"""
Add items to tpos table for storing various items (JSON format)
See `Item` class in models.
@@ -101,14 +111,14 @@ async def m006_items(db):
)


async def m007_atm_premium(db):
async def m007_atm_premium(db: Database):
"""
Add a premium % to ATM withdraws
"""
await db.execute("ALTER TABLE tpos.pos ADD COLUMN withdrawpremium FLOAT;")


async def m008_atm_time_option_and_pin_toggle(db):
async def m008_atm_time_option_and_pin_toggle(db: Database):
"""
Add a time mins/sec and pin toggle
"""
@@ -121,7 +131,7 @@ async def m008_atm_time_option_and_pin_toggle(db):
)


async def m009_tax_inclusive(db):
async def m009_tax_inclusive(db: Database):
"""
Add tax_inclusive column
"""
@@ -131,7 +141,7 @@ async def m009_tax_inclusive(db):
await db.execute("ALTER TABLE tpos.pos ADD COLUMN tax_default FLOAT DEFAULT 0;")


async def m010_rename_tpos_withdraw_columns(db):
async def m010_rename_tpos_withdraw_columns(db: Database):
"""
Add rename tpos withdraw columns
"""

0 comments on commit 5e25d80

Please sign in to comment.