lnbits / satspay

Create onchain and LN charges
MIT License
8 stars 4 forks source link

Upgrade to 0.2.5 from 0.2.4 fails / breaks Satspay extension install. Reverting to 0.2.3 fixes. #24

Closed santyr closed 1 year ago

santyr commented 1 year ago

LNbits version: 0.11.0 Postgres database

Oct 09 20:04:10 AzagSat poetry[1027563]: 2023-10-09 20:04:10.41 | INFO | 216.147.125.12:0 - "GET /api/v1/extension/satspay/releases?usr=10fc3d214e0149378bc98aab68db161c HTTP/1.0" 200 Oct 09 20:04:22 AzagSat poetry[1027563]: 2023-10-09 20:04:22.24 | INFO | Downloading extension satspay (0.2.5). Oct 09 20:04:22 AzagSat poetry[1027563]: 2023-10-09 20:04:22.87 | INFO | Extracting extension satspay (0.2.5). Oct 09 20:04:22 AzagSat poetry[1027563]: 2023-10-09 20:04:22.88 | SUCCESS | Extension SatsPay Server (0.2.5) installed. Oct 09 20:04:22 AzagSat poetry[1027563]: running migration satspay-41c772d7b641b21a4a8688284c0b9c7b5b5ff89d2fc784cfcb4e78b601640bd2.6 Oct 09 20:04:22 AzagSat poetry[1027563]: 2023-10-09 20:04:22.89 | WARNING | (psycopg2.errors.DuplicateColumn) column "zeroconf" of relation "charges" already exists Oct 09 20:04:22 AzagSat poetry[1027563]: [SQL: ALTER TABLE satspay.charges ADD COLUMN zeroconf BOOLEAN NOT NULL DEFAULT FALSE;] Oct 09 20:04:22 AzagSat poetry[1027563]: (Background on this error at: http://sqlalche.me/e/13/f405) Oct 09 20:04:22 AzagSat poetry[1027563]: 2023-10-09 20:04:22.90 | ERROR | HTTPException 500: Failed to install extension satspay (0.2.5).

santyr commented 1 year ago

This could be fixed in a couple ways:

  1. modify the m006_add_zeroconf_column function to first check if the column exists before attempting to add it.
async def m006_add_zeroconf_column(db):
    """
    Add 'zeroconf' column for allowing zero confirmation payments
    """
    try:
        # First, check if the column 'zeroconf' already exists
        column_exists = await db.fetch_one(
            """SELECT column_name FROM information_schema.columns WHERE table_name = 'satspay.charges' AND column_name = 'zeroconf';"""
        )
        if column_exists is None:
            await db.execute(
                f"ALTER TABLE satspay.charges ADD COLUMN zeroconf BOOLEAN NOT NULL DEFAULT FALSE;"
            )

            await db.execute(
                """
                UPDATE satspay.charges
                SET zeroconf = FALSE
                """
            )
    except OperationalError:
        pass
  1. Ignore the error
except OperationalError as e:
    # Log the error message but continue
    print(f"An error occurred: {e}")
    pass
talvasconcelos commented 1 year ago

I could reproduce the error. Trying to fix the bug ASAP!

santyr commented 1 year ago

Tried an uninstall with deleting data in an attempt to migrate to the most current version. This broke the ability to reinstall altogether. With errors related to the zeroconf column.

Manually running deletions fixed the breakage, and I was able to install 0.2.5 afterwards:

DROP TABLE IF EXISTS satspay.charges; DROP TABLE IF EXISTS satspay.themes;

dni commented 1 year ago

you need to look at the dbversions table and set it the to correct version.

sqlite3 data/database.sqlite3 "UPDATE dbversions set version=0 where db='boltz'"

santyr commented 1 year ago

I forgot to mention that. There were two versions for satspay in the dbversions table. I deleted both before reinstalling using the extensions interface.

Also, all of this is using the postgres db.

Thanks!

motorina0 commented 1 year ago

I forgot to mention that. There were two versions for satspay in the dbversions table. I deleted both before reinstalling using the extensions interface.

Thank you! I have managed to reproduce the issue. I have open an PR (https://github.com/lnbits/lnbits/pull/2039) with the fix.

talvasconcelos commented 1 year ago

Will be fixed on latest release 0.11.1