Skip to content

Commit 3e8dfec

Browse files
committed
Create results database if it's missing
1 parent a712968 commit 3e8dfec

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

flextool3/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,15 @@ def _ensure_database_up_to_date(func, database, request, pk):
147147
project = get_object_or_404(Project, pk=pk)
148148
if database == Database.MODEL:
149149
db_path = project.model_database_path()
150+
create_database = False
150151
else:
151152
db_path = project.results_database_path()
153+
create_database = not db_path.exists()
154+
if create_database:
155+
db_path.parent.mkdir(parents=True, exist_ok=True)
152156
db_url = "sqlite:///" + str(db_path)
153157
try:
154-
db_map = DatabaseMapping(db_url)
158+
db_map = DatabaseMapping(db_url, create=create_database)
155159
except SpineDBVersionError:
156160
_backup_database(db_path)
157161
try:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[tool.black]
2-
exclude = '\.git|migrations|static|templates|vue_frontend|manage.py|master_project|user_projects'
2+
exclude = '\.git|migrations|static|templates|vue_frontend|manage.py|master_project|user_projects|src'

0 commit comments

Comments
 (0)