diff --git a/migrations/2024-02-20-210617_user_info/up.sql b/migrations/2024-02-20-210617_user_info/up.sql
index e092982..3e0774d 100644
--- a/migrations/2024-02-20-210617_user_info/up.sql
+++ b/migrations/2024-02-20-210617_user_info/up.sql
@@ -4,7 +4,8 @@ CREATE TABLE app_user (
name VARCHAR(255) NOT NULL UNIQUE,
unblinded_msg VARCHAR(255) NOT NULL UNIQUE,
federation_id VARCHAR(64) NOT NULL,
- federation_invite_code VARCHAR(255) NOT NULL
+ federation_invite_code VARCHAR(255) NOT NULL,
+ invoice_index INTEGER NOT NULL DEFAULT 0
);
CREATE INDEX idx_app_user_unblinded_msg ON app_user (unblinded_msg);
@@ -16,6 +17,7 @@ CREATE TABLE invoice (
op_id VARCHAR(64) NOT NULL,
preimage VARCHAR(64) NOT NULL,
app_user_id INTEGER NOT NULL references app_user(id),
+ user_invoice_index INTEGER NOT NULL,
bolt11 VARCHAR(2048) NOT NULL,
amount BIGINT NOT NULL,
state INTEGER NOT NULL DEFAULT 0
diff --git a/src/db.rs b/src/db.rs
index a244d65..4ab7f7e 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -21,6 +21,7 @@ pub(crate) trait DBConnection {
fn set_invoice_state(&self, invoice: Invoice, s: i32) -> anyhow::Result<()>;
fn get_user_by_name(&self, name: String) -> anyhow::Result