diff options
author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-03-16 12:48:31 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-03-24 20:25:01 +0000 |
commit | ed2cbfa4e5ebd12a626022c4c449b1accbe1caf2 (patch) | |
tree | 6ac3843e353dc2737349667dd53d146ba8abdda8 | |
parent | e9078e0bb6ea597adbeaab406ccf965dc9cb38fc (diff) | |
download | paste-ed2cbfa4e5ebd12a626022c4c449b1accbe1caf2.tar.gz paste-ed2cbfa4e5ebd12a626022c4c449b1accbe1caf2.tar.xz paste-ed2cbfa4e5ebd12a626022c4c449b1accbe1caf2.zip |
prevent accessing a future database version
-rw-r--r-- | paste/db.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/paste/db.py b/paste/db.py index 692b01f..25e85ce 100644 --- a/paste/db.py +++ b/paste/db.py @@ -51,6 +51,10 @@ def get_version(connection: sqlite3.Connection) -> int: def migrate(connection: sqlite3.Connection, migrations: list[str]) -> None: version = get_version(connection) + if len(migrations) < version: + raise RuntimeError( + f"Attempt to downgrade from v{version} to v{len(migrations)}" + ) for i in count(version + 1): if i - 1 >= len(migrations): break |