Skip to content

Commit 71e2b3e

Browse files
committed
Build the old schema directly in the migration test, instead of DROP COLUMN
1 parent da35332 commit 71e2b3e

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

‎tests/test_conditional_fetch.py‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,33 @@ def test_set_unchanged_keeps_the_text_and_the_copy(db):
189189
assert store.saved_copy("https://good.example/").html
190190

191191

192-
@pytest.mark.skipif(
193-
sqlite3.sqlite_version_info < (3, 35), reason="ALTER TABLE ... DROP COLUMN needs SQLite 3.35"
194-
)
192+
# The bookmarks table as version 6 created it, before the validator columns.
193+
VERSION_6 = """
194+
DROP TABLE bookmarks;
195+
CREATE TABLE bookmarks (
196+
id INTEGER PRIMARY KEY,
197+
url TEXT NOT NULL UNIQUE,
198+
title TEXT NOT NULL DEFAULT '',
199+
folder TEXT NOT NULL DEFAULT '',
200+
added_at TEXT,
201+
fetched_at TEXT,
202+
fetch_error TEXT,
203+
error_kind TEXT,
204+
source TEXT,
205+
tags TEXT NOT NULL DEFAULT '',
206+
browser_tags TEXT NOT NULL DEFAULT '',
207+
my_tags TEXT NOT NULL DEFAULT '',
208+
note TEXT NOT NULL DEFAULT ''
209+
);
210+
PRAGMA user_version = 6;
211+
"""
212+
213+
195214
def test_migration_adds_the_validator_columns(tmp_path):
196215
path = tmp_path / "db.sqlite"
197216
Store(path).close()
198217
db = sqlite3.connect(path)
199-
db.executescript(
200-
"ALTER TABLE bookmarks DROP COLUMN etag;"
201-
"ALTER TABLE bookmarks DROP COLUMN last_modified;"
202-
"PRAGMA user_version = 6;"
203-
)
218+
db.executescript(VERSION_6)
204219
db.close()
205220
with Store(path) as store:
206221
assert store.db.execute("PRAGMA user_version").fetchone()[0] == SCHEMA_VERSION

0 commit comments

Comments
 (0)