Add per-adventure "Sync from library" for scripts
Adventure scripts are frozen snapshots taken at creation. Add an opt-in
way to pull the latest library code into a live adventure:
- AdventureScript.source_script_id links a copy to its library Script
(migration 24; set at adventure creation)
- list endpoint flags out_of_date by diffing copy vs library
- POST /adventures/{id}/scripts/{sid}/sync overwrites the copy's code,
preserving enabled/position/script_state
- legacy copies with no link fall back to a name match, then adopt the link
- Play page shows a Sync button only when a copy differs from its library
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEpWMjnfPqzZ13nPMoGhs5
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
94db6e055b
commit
328ae8942d
@@ -71,6 +71,10 @@ MIGRATIONS: list[tuple[int, str]] = [
|
||||
(21, "ALTER TABLE settings ADD COLUMN user_id INTEGER REFERENCES users(id) ON DELETE CASCADE"),
|
||||
(22, "UPDATE settings SET user_id = 1"),
|
||||
(23, "CREATE UNIQUE INDEX IF NOT EXISTS ix_settings_user_id ON settings (user_id)"),
|
||||
# Link each adventure-script copy back to its library Script so it can be
|
||||
# re-synced on demand. NULL for copies made before this column existed.
|
||||
(24, "ALTER TABLE adventure_scripts ADD COLUMN source_script_id INTEGER "
|
||||
"REFERENCES scripts(id) ON DELETE SET NULL"),
|
||||
]
|
||||
|
||||
LATEST_VERSION = max((v for v, _ in MIGRATIONS), default=1)
|
||||
|
||||
Reference in New Issue
Block a user