fix(523): the backup carries user_profiles - the Profile page travels with its user (#5879)
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 15s
CI & Build / TypeScript typecheck (push) Successful in 54s
CI & Build / integration (push) Successful in 1m9s
CI & Build / Python tests (push) Successful in 1m56s
CI & Build / Build & push image (push) Successful in 27s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 15s
CI & Build / TypeScript typecheck (push) Successful in 54s
CI & Build / integration (push) Successful in 1m9s
CI & Build / Python tests (push) Successful in 1m56s
CI & Build / Build & push image (push) Successful in 27s
Settings -> Profile (name, role, expertise, response style, tone, interests, working hours) is typed by its user and neither derived nor a credential, yet _NOT_INCLUDED named it, so a restore dropped it without a word. BACKUP_VERSION 26. Both exports carry it; the restore remaps only the user, and a blank field stays blank rather than restoring as the page's default. The column and import guards cover it, and the tar round-trip restores one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ from scribe.models.milestone import Milestone
|
||||
from scribe.models.note import Note
|
||||
from scribe.models.project import Project
|
||||
from scribe.models.user import User
|
||||
from scribe.models.user_profile import UserProfile
|
||||
from scribe.restore import load_backup, run
|
||||
from scribe.services import backup
|
||||
from scribe.services.backup_file import write_archive
|
||||
@@ -64,6 +65,10 @@ async def written(tmp_path):
|
||||
title="Prove the restore", body="From the tar, not the JSON.",
|
||||
status="todo", note_type="note", task_kind="work")
|
||||
s.add(note)
|
||||
profile = UserProfile(user_id=user.id, display_name="Drill Owner",
|
||||
tone="technical", interests=["backups"],
|
||||
work_schedule={"start": "09:00"})
|
||||
s.add(profile)
|
||||
await s.commit()
|
||||
payload = {
|
||||
"version": backup.BACKUP_VERSION,
|
||||
@@ -72,6 +77,7 @@ async def written(tmp_path):
|
||||
"projects": backup._project_rows([project]),
|
||||
"milestones": backup._milestone_rows([milestone]),
|
||||
"notes": backup._note_rows([note]),
|
||||
"user_profiles": backup._user_profile_rows([profile]),
|
||||
}
|
||||
payload["users"][0]["username"] = RESTORED
|
||||
from datetime import datetime, timezone
|
||||
@@ -88,10 +94,19 @@ async def test_the_tar_restores_with_every_id_remapped(written):
|
||||
project = (await s.execute(select(Project).where(Project.user_id == user.id))).scalars().one()
|
||||
milestone = (await s.execute(select(Milestone).where(Milestone.user_id == user.id))).scalars().one()
|
||||
note = (await s.execute(select(Note).where(Note.user_id == user.id))).scalars().one()
|
||||
profile = (await s.execute(
|
||||
select(UserProfile).where(UserProfile.user_id == user.id)
|
||||
)).scalars().one()
|
||||
assert project.title == "Restore drill"
|
||||
assert (note.project_id, note.milestone_id) == (project.id, milestone.id)
|
||||
assert note.body == "From the tar, not the JSON."
|
||||
assert note.status == "todo"
|
||||
# The Profile page travels with its user (#5879); a field left blank stays
|
||||
# blank rather than restoring as the page's default.
|
||||
assert (profile.display_name, profile.tone) == ("Drill Owner", "technical")
|
||||
assert profile.interests == ["backups"]
|
||||
assert profile.work_schedule == {"start": "09:00"}
|
||||
assert profile.job_title is None
|
||||
|
||||
|
||||
async def test_the_command_refuses_a_database_with_accounts(written):
|
||||
|
||||
@@ -27,7 +27,7 @@ def test_backup_version_is_current():
|
||||
|
||||
(Named for the number it asserted until v10, which is exactly the drift a
|
||||
name-carrying-a-value invites; it now says what it checks.)"""
|
||||
assert backup.BACKUP_VERSION == 25
|
||||
assert backup.BACKUP_VERSION == 26
|
||||
|
||||
|
||||
def _exportable_note(**over):
|
||||
@@ -166,6 +166,7 @@ def _column_guard_targets():
|
||||
from scribe.models.system import RecordSystem, System
|
||||
from scribe.models.task_log import TaskLog
|
||||
from scribe.models.user import User
|
||||
from scribe.models.user_profile import UserProfile
|
||||
|
||||
return {
|
||||
"users": (User, backup._user_rows),
|
||||
@@ -213,6 +214,7 @@ def _column_guard_targets():
|
||||
"family_idea_references": (FamilyIdeaReference, backup._family_idea_reference_rows),
|
||||
"family_adoptions": (FamilyAdoption, backup._family_adoption_rows),
|
||||
"family_decisions": (FamilyDecision, backup._family_decision_rows),
|
||||
"user_profiles": (UserProfile, backup._user_profile_rows),
|
||||
}
|
||||
|
||||
|
||||
@@ -326,6 +328,7 @@ def _import_guard_targets():
|
||||
"system_usage_events": backup._build_system_usage_event,
|
||||
"retrieval_tuning_events": backup._build_retrieval_tuning_event,
|
||||
"moment_mappings": backup._build_moment_mapping,
|
||||
"user_profiles": backup._build_user_profile,
|
||||
"design_systems": backup._build_design_system,
|
||||
"design_tokens": backup._build_design_token,
|
||||
"repo_bindings": backup._build_repo_binding,
|
||||
@@ -599,7 +602,9 @@ async def test_export_full_backup_contains_every_declared_section():
|
||||
# v25: family canon (milestone 463).
|
||||
"platforms", "project_platforms", "family_ideas",
|
||||
"family_idea_platforms", "family_idea_references",
|
||||
"family_adoptions", "family_decisions"):
|
||||
"family_adoptions", "family_decisions",
|
||||
# v26: the Profile page (#5879).
|
||||
"user_profiles"):
|
||||
assert key in out, f"missing export section: {key}"
|
||||
assert out[key] == []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user