From 4c0f3e1da9cc4b355655d73aa08b438bd60d7e13 Mon Sep 17 00:00:00 2001 From: CleverThis Date: Tue, 14 Apr 2026 17:35:00 +0000 Subject: [PATCH] fix(tests): fix create_template_db.py to create writable SQLite template database Added os.chmod(db_path, 0o664) after database creation to ensure the template database has writable permissions. This prevents sqlite3.OperationalError: attempt to write a readonly database when tests copy and modify the template during test setup. The template database is now created with rw-rw-r-- (664) permissions instead of the default rw-r--r-- (644), allowing the test runner process to write to it. ISSUES CLOSED: #9372 --- scripts/create_template_db.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/create_template_db.py b/scripts/create_template_db.py index 46b662df9..136d103bb 100644 --- a/scripts/create_template_db.py +++ b/scripts/create_template_db.py @@ -10,6 +10,7 @@ Usage: Default output: build/.template-migrated.db """ +import os import sys from pathlib import Path @@ -62,6 +63,11 @@ def create_template(output_path: str = "build/.template-migrated.db") -> None: engine.dispose() + # Ensure the template database is writable (0o664 = rw-rw-r--) + # This prevents sqlite3.OperationalError: attempt to write a readonly database + # when tests copy and modify the template during test setup. + os.chmod(str(out), 0o664) + if __name__ == "__main__": path = sys.argv[1] if len(sys.argv) > 1 else "build/.template-migrated.db" -- 2.52.0