feat: import private content from external bundles

This commit is contained in:
2026-09-16 10:13:17 +03:30
parent 9f749e7d81
commit db8f257a98
5 changed files with 137 additions and 65 deletions

View File

@@ -120,21 +120,34 @@ return 404 when accessed directly. Upload URLs are public and immutable, so
upload a replacement rather than overwrite an existing URL. Deleting content
does not recall files already cached by a visitor.
## Import this repository's original portfolio
## Import private portfolio content
New installations show generic samples. To preserve this repository's original
English/Persian content and project URLs, run the explicit import **before editing
any content**:
Personal content is supplied separately, never embedded in the application image.
A version-1 bundle contains `bundle.json` with `content` (settings, languages,
sections, entries) and `files` (original URL, relative file path, SHA-256, MIME,
width, height). Keep the bundle outside the Git checkout.
```sh
npm run maintenance -- import-legacy
# Or in Docker:
docker compose -f compose.selfhost.yaml exec portfolio-app node maintenance.mjs import-legacy
npm run maintenance -- import-legacy /absolute/path/to/private-bundle
```
The import is transactional and only replaces untouched samples. It refuses to
run twice or overwrite edits. Creating the owner account does not prevent import.
The source fixture is `src/seed/legacy.json`; startup never imports it implicitly.
The import validates the bundle before writing, preserves project IDs, copies
images into persistent uploads, and replaces only untouched sample content.
It refuses repeated imports or edited portfolios. Creating an owner is independent.
For an existing, edited installation, migrate only references to the old bundled
images before upgrading away from those assets:
```sh
npm run maintenance -- migrate-legacy-media /absolute/path/to/private-bundle
```
This operation preserves content and existing uploads and is safe to repeat.
Back up first. For Docker, mount the external bundle read-only at `/import` and
run `node maintenance.mjs import-legacy /import` (or `migrate-legacy-media`).
Do not copy the bundle into the image or repository. Git history is unchanged.
`create-user` is an alias for `create-owner`; neither runs at application startup.
## Backups and restore