fix migrations, add documentation, hopefully fix workflow (#899)

* fix migrations, add documentation, hopefully fix workflow

* renaming to test-migration and add migration

Co-authored-by: dni <dni.khr@gmail.com>
This commit is contained in:
dni ⚡ 2022-08-17 15:42:01 +02:00 committed by GitHub
parent 24de8f6611
commit d649e6a5c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 23 deletions

View file

@ -19,16 +19,12 @@ env.read_env()
# Change these values as needed
sqfolder = "data/"
sqfolder = env.str("LNBITS_DATA_FOLDER", default=None)
LNBITS_DATABASE_URL = env.str("LNBITS_DATABASE_URL", default=None)
if LNBITS_DATABASE_URL is None:
pgdb = "lnbits"
pguser = "lnbits"
pgpswd = "postgres"
pghost = "localhost"
pgport = "5432"
pgschema = ""
print("missing LNBITS_DATABASE_URL")
sys.exit(1)
else:
# parse postgres://lnbits:postgres@localhost:5432/lnbits
pgdb = LNBITS_DATABASE_URL.split("/")[-1]
@ -129,7 +125,7 @@ def migrate_db(file: str, schema: str, exclude_tables: List[str] = []):
sq = get_sqlite_cursor(file)
tables = sq.execute(
"""
SELECT name FROM sqlite_master
SELECT name FROM sqlite_master
WHERE type='table' AND name not like 'sqlite?_%' escape '?'
"""
).fetchall()