Collapse multiple invoice tables into one
This commit is contained in:
@@ -39,19 +39,13 @@ CREATE TABLE IF NOT EXISTS relay (
|
||||
FOREIGN KEY (tenant) REFERENCES tenant(pubkey)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS invoice_nwc_payment (
|
||||
invoice_id TEXT PRIMARY KEY,
|
||||
tenant_pubkey TEXT NOT NULL,
|
||||
state TEXT NOT NULL CHECK (state IN ('pending', 'paid')),
|
||||
created_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL,
|
||||
FOREIGN KEY (tenant_pubkey) REFERENCES tenant(pubkey)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS invoice_manual_lightning_payment (
|
||||
invoice_id TEXT PRIMARY KEY,
|
||||
CREATE TABLE IF NOT EXISTS lightning_invoice (
|
||||
stripe_invoice_id TEXT PRIMARY KEY,
|
||||
tenant_pubkey TEXT NOT NULL,
|
||||
bolt11 TEXT NOT NULL,
|
||||
status TEXT NOT NULL CHECK (status IN ('pending', 'paid')),
|
||||
paid_method TEXT CHECK (paid_method IN ('nwc', 'manual')),
|
||||
expires_at INTEGER NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL,
|
||||
FOREIGN KEY (tenant_pubkey) REFERENCES tenant(pubkey)
|
||||
@@ -69,8 +63,5 @@ CREATE INDEX IF NOT EXISTS idx_relay_tenant_status_plan
|
||||
CREATE INDEX IF NOT EXISTS idx_activity_resource_type_resource_id_created_at_id
|
||||
ON activity (resource_type, resource_id, created_at DESC, id DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_invoice_nwc_payment_tenant_pubkey
|
||||
ON invoice_nwc_payment (tenant_pubkey);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_invoice_manual_lightning_payment_tenant_pubkey
|
||||
ON invoice_manual_lightning_payment (tenant_pubkey);
|
||||
CREATE INDEX IF NOT EXISTS idx_lightning_invoice_tenant_pubkey
|
||||
ON lightning_invoice (tenant_pubkey);
|
||||
|
||||
Reference in New Issue
Block a user